From: Christopher Heiny <hidden> Date: 2014-02-11 23:13:33
For rmi_sensor and rmi_function device_types, use put_device() and
the assocated device_type.release() function to clean up related
structures and storage in the correct and safe order.
Signed-off-by: Christopher Heiny <redacted>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Benjamin Tissoires <redacted>
Cc: Linux Walleij <redacted>
Cc: David Herrmann <redacted>
Cc: Jiri Kosina <redacted>
Cc: Courtney Cavin <redacted>
---
drivers/input/rmi4/rmi_bus.c | 65 +++++++++++++++--------------------------
drivers/input/rmi4/rmi_driver.c | 11 ++-----
2 files changed, 25 insertions(+), 51 deletions(-)
@@ -139,21 +122,6 @@ EXPORT_SYMBOL(rmi_unregister_transport_device);/* Function specific stuff */-staticvoidrmi_release_function(structdevice*dev)-{-structrmi_function*fn=to_rmi_function(dev);-kfree(fn);-}--structdevice_typermi_function_type={-.name="rmi_function",-.release=rmi_release_function,-};--boolrmi_is_function_device(structdevice*dev)-{-returndev->type==&rmi_function_type;-}#ifdef CONFIG_RMI4_DEBUG
@@ -674,8 +674,7 @@ static int rmi_create_function(struct rmi_device *rmi_dev,if(!fn->irq_mask){dev_err(dev,"%s: Failed to create irq_mask for F%02X.\n",__func__,pdt->function_number);-error=-ENOMEM;-gotoerr_free_mem;+return-ENOMEM;}for(i=0;i<fn->num_of_irqs;i++)
@@ -683,7 +682,7 @@ static int rmi_create_function(struct rmi_device *rmi_dev,error=rmi_register_function(fn);if(error)-gotoerr_free_irq_mask;+returnerror;if(pdt->function_number==0x01)data->f01_container=fn;
@@ -691,12 +690,6 @@ static int rmi_create_function(struct rmi_device *rmi_dev,list_add_tail(&fn->node,&data->function_list);returnRMI_SCAN_CONTINUE;--err_free_irq_mask:-kfree(fn->irq_mask);-err_free_mem:-kfree(fn);-returnerror;}#ifdef CONFIG_PM_SLEEP
From: Courtney Cavin <hidden> Date: 2014-02-12 01:57:46
On Wed, Feb 12, 2014 at 12:13:30AM +0100, Christopher Heiny wrote:
For rmi_sensor and rmi_function device_types, use put_device() and
the assocated device_type.release() function to clean up related
structures and storage in the correct and safe order.
Signed-off-by: Christopher Heiny <redacted>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Benjamin Tissoires <redacted>
Cc: Linux Walleij <redacted>
Cc: David Herrmann <redacted>
Cc: Jiri Kosina <redacted>
Cc: Courtney Cavin <redacted>
I'm not a huge fan of you taking my patches, re-formatting them and
sending them as your own. More out of principle then actually caring
about ownership. You at least cc'd me on this one....
From: Christopher Heiny <hidden> Date: 2014-02-12 02:17:58
On 02/11/2014 05:59 PM, Courtney Cavin wrote:
On Wed, Feb 12, 2014 at 12:13:30AM +0100, Christopher Heiny wrote:
quoted
For rmi_sensor and rmi_function device_types, use put_device() and
the assocated device_type.release() function to clean up related
structures and storage in the correct and safe order.
Signed-off-by: Christopher Heiny <redacted>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Benjamin Tissoires <redacted>
Cc: Linux Walleij <redacted>
Cc: David Herrmann <redacted>
Cc: Jiri Kosina <redacted>
Cc: Courtney Cavin <redacted>
I'm not a huge fan of you taking my patches, re-formatting them and
sending them as your own. More out of principle then actually caring
about ownership. You at least cc'd me on this one....
Sorry - no slight was intended at all! I wasn't sure what the protocol
was for picking up an idea from someone else's patch and building on
that idea, so I just went with the CC. I definitely prefer to attribute
sources correctly - if you could clarify what should be done (beyond the
CC) to acknowledge the author of the original patch, I'd appreciate it.
From: Courtney Cavin <hidden> Date: 2014-02-12 02:47:58
On Wed, Feb 12, 2014 at 03:17:57AM +0100, Christopher Heiny wrote:
On 02/11/2014 05:59 PM, Courtney Cavin wrote:
quoted
On Wed, Feb 12, 2014 at 12:13:30AM +0100, Christopher Heiny wrote:
quoted
For rmi_sensor and rmi_function device_types, use put_device() and
the assocated device_type.release() function to clean up related
structures and storage in the correct and safe order.
Signed-off-by: Christopher Heiny <redacted>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Benjamin Tissoires <redacted>
Cc: Linux Walleij <redacted>
Cc: David Herrmann <redacted>
Cc: Jiri Kosina <redacted>
Cc: Courtney Cavin <redacted>
I'm not a huge fan of you taking my patches, re-formatting them and
sending them as your own. More out of principle then actually caring
about ownership. You at least cc'd me on this one....
Sorry - no slight was intended at all! I wasn't sure what the protocol
was for picking up an idea from someone else's patch and building on
that idea, so I just went with the CC. I definitely prefer to attribute
sources correctly - if you could clarify what should be done (beyond the
CC) to acknowledge the author of the original patch, I'd appreciate it.
Sure. In short, follow Documentation/SubmittingPatches , esp. section
12) Sign your work.
Generally the patch should read something like the following:
From: Original Author [off-list ref]
*BLURB*
Signed-off-by: Original Author [off-list ref]
[additional.author@example.org: changed x and y]
Signed-off-by: Additional Author [off-list ref]
Assuming the original author actually signed-off the patch in the first
place, of course. The square bracket part is optional, but can be
helpful for reviewers.
I'm somewhat surprised that you are not aware of this procedure, as this
is how Dmitry has replied to some of your patches in the past.
-Courtney
From: Christopher Heiny <hidden> Date: 2014-02-12 03:18:00
On 02/11/2014 06:49 PM, Courtney Cavin wrote:
On Wed, Feb 12, 2014 at 03:17:57AM +0100, Christopher Heiny wrote:
quoted
On 02/11/2014 05:59 PM, Courtney Cavin wrote:
quoted
On Wed, Feb 12, 2014 at 12:13:30AM +0100, Christopher Heiny wrote:
quoted
For rmi_sensor and rmi_function device_types, use put_device() and
the assocated device_type.release() function to clean up related
structures and storage in the correct and safe order.
Signed-off-by: Christopher Heiny <redacted>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Benjamin Tissoires <redacted>
Cc: Linux Walleij <redacted>
Cc: David Herrmann <redacted>
Cc: Jiri Kosina <redacted>
Cc: Courtney Cavin <redacted>
I'm not a huge fan of you taking my patches, re-formatting them and
sending them as your own. More out of principle then actually caring
about ownership. You at least cc'd me on this one....
Sorry - no slight was intended at all! I wasn't sure what the protocol
was for picking up an idea from someone else's patch and building on
that idea, so I just went with the CC. I definitely prefer to attribute
sources correctly - if you could clarify what should be done (beyond the
CC) to acknowledge the author of the original patch, I'd appreciate it.
Sure. In short, follow Documentation/SubmittingPatches , esp. section
12) Sign your work.
Generally the patch should read something like the following:
From: Original Author [off-list ref]
*BLURB*
Signed-off-by: Original Author [off-list ref]
[additional.author@example.org: changed x and y]
Signed-off-by: Additional Author [off-list ref]
Assuming the original author actually signed-off the patch in the first
place, of course. The square bracket part is optional, but can be
helpful for reviewers.
I'm somewhat surprised that you are not aware of this procedure, as this
is how Dmitry has replied to some of your patches in the past.'
Thanks very much.
I was actually aware of that, but thought the work was sufficiently
different from your original patch that applying your Signed-off-by: to
it wouldn't be appropriate (I dislike being signed off on things I don't
necessarily agree with as much as lack of attribution). I'll be less
paranoid about that in the future.
From: Courtney Cavin <hidden> Date: 2014-02-12 04:53:09
On Wed, Feb 12, 2014 at 04:17:59AM +0100, Christopher Heiny wrote:
On 02/11/2014 06:49 PM, Courtney Cavin wrote:
quoted
On Wed, Feb 12, 2014 at 03:17:57AM +0100, Christopher Heiny wrote:
quoted
On 02/11/2014 05:59 PM, Courtney Cavin wrote:
quoted
On Wed, Feb 12, 2014 at 12:13:30AM +0100, Christopher Heiny wrote:
quoted
For rmi_sensor and rmi_function device_types, use put_device() and
the assocated device_type.release() function to clean up related
structures and storage in the correct and safe order.
Signed-off-by: Christopher Heiny <redacted>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Benjamin Tissoires <redacted>
Cc: Linux Walleij <redacted>
Cc: David Herrmann <redacted>
Cc: Jiri Kosina <redacted>
Cc: Courtney Cavin <redacted>
I'm not a huge fan of you taking my patches, re-formatting them and
sending them as your own. More out of principle then actually caring
about ownership. You at least cc'd me on this one....
Sorry - no slight was intended at all! I wasn't sure what the protocol
was for picking up an idea from someone else's patch and building on
that idea, so I just went with the CC. I definitely prefer to attribute
sources correctly - if you could clarify what should be done (beyond the
CC) to acknowledge the author of the original patch, I'd appreciate it.
Sure. In short, follow Documentation/SubmittingPatches , esp. section
12) Sign your work.
Generally the patch should read something like the following:
From: Original Author [off-list ref]
*BLURB*
Signed-off-by: Original Author [off-list ref]
[additional.author@example.org: changed x and y]
Signed-off-by: Additional Author [off-list ref]
Assuming the original author actually signed-off the patch in the first
place, of course. The square bracket part is optional, but can be
helpful for reviewers.
I'm somewhat surprised that you are not aware of this procedure, as this
is how Dmitry has replied to some of your patches in the past.'
Thanks very much.
I was actually aware of that, but thought the work was sufficiently
different from your original patch that applying your Signed-off-by: to
it wouldn't be appropriate (I dislike being signed off on things I don't
necessarily agree with as much as lack of attribution). I'll be less
paranoid about that in the future.
I don't see how they were different enough, when clearly these two
patches attempt to fix the same bugs, using the same methods with
slightly modified flow. Perhaps the patches may be small enough
to be interpreted either way, but at the very least reported-by (since
this is a bug-fix) or suggested-by is more appropriate than Cc. This is
a public list, so I'm sure someone will tell you when you are wrong, if
nothing else.
Along the same topic, I guess I should also mention that it is typically
frowned upon to takeover someone else's patches without giving them
due-time to fix any outstanding review comments.
In both of these cases, you neither asked for me to submit the patches
separately, outside of my DT-series, nor to make any specific changes.
I was under the impression that you were still participating in the
discussion for that series.
While it is apparent that we have differing views on how this particular
driver development should proceed, and we should definitely discuss
them, please do not think that I'm not willing to apply my patches
individually to what's in tree now.
My main concern here is that I cannot actually properly test this driver
without DT, non-gpio irq, and regulator support. Likewise, pre-3.7 is
ancient, and would require back-porting hundreds of changes.
-Courtney
On Tue, Feb 11, 2014 at 08:54:53PM -0800, Courtney Cavin wrote:
On Wed, Feb 12, 2014 at 04:17:59AM +0100, Christopher Heiny wrote:
quoted
On 02/11/2014 06:49 PM, Courtney Cavin wrote:
quoted
On Wed, Feb 12, 2014 at 03:17:57AM +0100, Christopher Heiny wrote:
quoted
On 02/11/2014 05:59 PM, Courtney Cavin wrote:
quoted
On Wed, Feb 12, 2014 at 12:13:30AM +0100, Christopher Heiny wrote:
quoted
For rmi_sensor and rmi_function device_types, use put_device() and
the assocated device_type.release() function to clean up related
structures and storage in the correct and safe order.
Signed-off-by: Christopher Heiny <redacted>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Benjamin Tissoires <redacted>
Cc: Linux Walleij <redacted>
Cc: David Herrmann <redacted>
Cc: Jiri Kosina <redacted>
Cc: Courtney Cavin <redacted>
I'm not a huge fan of you taking my patches, re-formatting them and
sending them as your own. More out of principle then actually caring
about ownership. You at least cc'd me on this one....
Sorry - no slight was intended at all! I wasn't sure what the protocol
was for picking up an idea from someone else's patch and building on
that idea, so I just went with the CC. I definitely prefer to attribute
sources correctly - if you could clarify what should be done (beyond the
CC) to acknowledge the author of the original patch, I'd appreciate it.
Sure. In short, follow Documentation/SubmittingPatches , esp. section
12) Sign your work.
Generally the patch should read something like the following:
From: Original Author [off-list ref]
*BLURB*
Signed-off-by: Original Author [off-list ref]
[additional.author@example.org: changed x and y]
Signed-off-by: Additional Author [off-list ref]
Assuming the original author actually signed-off the patch in the first
place, of course. The square bracket part is optional, but can be
helpful for reviewers.
I'm somewhat surprised that you are not aware of this procedure, as this
is how Dmitry has replied to some of your patches in the past.'
Thanks very much.
I was actually aware of that, but thought the work was sufficiently
different from your original patch that applying your Signed-off-by: to
it wouldn't be appropriate (I dislike being signed off on things I don't
necessarily agree with as much as lack of attribution). I'll be less
paranoid about that in the future.
I don't see how they were different enough, when clearly these two
patches attempt to fix the same bugs, using the same methods with
slightly modified flow. Perhaps the patches may be small enough
to be interpreted either way, but at the very least reported-by (since
this is a bug-fix) or suggested-by is more appropriate than Cc. This is
a public list, so I'm sure someone will tell you when you are wrong, if
nothing else.
Along the same topic, I guess I should also mention that it is typically
frowned upon to takeover someone else's patches without giving them
due-time to fix any outstanding review comments.
In both of these cases, you neither asked for me to submit the patches
separately, outside of my DT-series, nor to make any specific changes.
I was under the impression that you were still participating in the
discussion for that series.
While it is apparent that we have differing views on how this particular
driver development should proceed, and we should definitely discuss
them, please do not think that I'm not willing to apply my patches
individually to what's in tree now.
My main concern here is that I cannot actually properly test this driver
without DT, non-gpio irq, and regulator support. Likewise, pre-3.7 is
ancient, and would require back-porting hundreds of changes.
I can rebase to something more recent; I just did not want to cause
additional work for Chris. Once he finishes pushing his code I was going
to rebase anyway.
Thanks.
--
Dmitry
From: Courtney Cavin <hidden> Date: 2014-02-12 17:07:27
On Wed, Feb 12, 2014 at 07:43:42AM +0100, Dmitry Torokhov wrote:
On Tue, Feb 11, 2014 at 08:54:53PM -0800, Courtney Cavin wrote:
quoted
On Wed, Feb 12, 2014 at 04:17:59AM +0100, Christopher Heiny wrote:
quoted
On 02/11/2014 06:49 PM, Courtney Cavin wrote:
quoted
On Wed, Feb 12, 2014 at 03:17:57AM +0100, Christopher Heiny wrote:
quoted
On 02/11/2014 05:59 PM, Courtney Cavin wrote:
quoted
On Wed, Feb 12, 2014 at 12:13:30AM +0100, Christopher Heiny wrote:
quoted
For rmi_sensor and rmi_function device_types, use put_device() and
the assocated device_type.release() function to clean up related
structures and storage in the correct and safe order.
Signed-off-by: Christopher Heiny <redacted>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Benjamin Tissoires <redacted>
Cc: Linux Walleij <redacted>
Cc: David Herrmann <redacted>
Cc: Jiri Kosina <redacted>
Cc: Courtney Cavin <redacted>
I'm not a huge fan of you taking my patches, re-formatting them and
sending them as your own. More out of principle then actually caring
about ownership. You at least cc'd me on this one....
Sorry - no slight was intended at all! I wasn't sure what the protocol
was for picking up an idea from someone else's patch and building on
that idea, so I just went with the CC. I definitely prefer to attribute
sources correctly - if you could clarify what should be done (beyond the
CC) to acknowledge the author of the original patch, I'd appreciate it.
Sure. In short, follow Documentation/SubmittingPatches , esp. section
12) Sign your work.
Generally the patch should read something like the following:
From: Original Author [off-list ref]
*BLURB*
Signed-off-by: Original Author [off-list ref]
[additional.author@example.org: changed x and y]
Signed-off-by: Additional Author [off-list ref]
Assuming the original author actually signed-off the patch in the first
place, of course. The square bracket part is optional, but can be
helpful for reviewers.
I'm somewhat surprised that you are not aware of this procedure, as this
is how Dmitry has replied to some of your patches in the past.'
Thanks very much.
I was actually aware of that, but thought the work was sufficiently
different from your original patch that applying your Signed-off-by: to
it wouldn't be appropriate (I dislike being signed off on things I don't
necessarily agree with as much as lack of attribution). I'll be less
paranoid about that in the future.
I don't see how they were different enough, when clearly these two
patches attempt to fix the same bugs, using the same methods with
slightly modified flow. Perhaps the patches may be small enough
to be interpreted either way, but at the very least reported-by (since
this is a bug-fix) or suggested-by is more appropriate than Cc. This is
a public list, so I'm sure someone will tell you when you are wrong, if
nothing else.
Along the same topic, I guess I should also mention that it is typically
frowned upon to takeover someone else's patches without giving them
due-time to fix any outstanding review comments.
In both of these cases, you neither asked for me to submit the patches
separately, outside of my DT-series, nor to make any specific changes.
I was under the impression that you were still participating in the
discussion for that series.
While it is apparent that we have differing views on how this particular
driver development should proceed, and we should definitely discuss
them, please do not think that I'm not willing to apply my patches
individually to what's in tree now.
My main concern here is that I cannot actually properly test this driver
without DT, non-gpio irq, and regulator support. Likewise, pre-3.7 is
ancient, and would require back-porting hundreds of changes.
I can rebase to something more recent; I just did not want to cause
additional work for Chris. Once he finishes pushing his code I was going
to rebase anyway.
On Tue, Feb 11, 2014 at 03:13:30PM -0800, Christopher Heiny wrote:
quoted hunk
For rmi_sensor and rmi_function device_types, use put_device() and
the assocated device_type.release() function to clean up related
structures and storage in the correct and safe order.
Signed-off-by: Christopher Heiny <redacted>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Benjamin Tissoires <redacted>
Cc: Linux Walleij <redacted>
Cc: David Herrmann <redacted>
Cc: Jiri Kosina <redacted>
Cc: Courtney Cavin <redacted>
---
drivers/input/rmi4/rmi_bus.c | 65 +++++++++++++++--------------------------
drivers/input/rmi4/rmi_driver.c | 11 ++-----
2 files changed, 25 insertions(+), 51 deletions(-)
@@ -139,21 +122,6 @@ EXPORT_SYMBOL(rmi_unregister_transport_device);/* Function specific stuff */-staticvoidrmi_release_function(structdevice*dev)-{-structrmi_function*fn=to_rmi_function(dev);-kfree(fn);-}--structdevice_typermi_function_type={-.name="rmi_function",-.release=rmi_release_function,-};--boolrmi_is_function_device(structdevice*dev)-{-returndev->type==&rmi_function_type;-}#ifdef CONFIG_RMI4_DEBUG
This is wrong, rmi_release_function should finish cleaning up resources,
however unregistration part should happen much earlier. If someone takes
reference to the device in debugfs the device may never go away as noone
will kick the user out.
Please put the calls to rmi_function_teardown_debugfs() back where they
originally were.
@@ -674,8 +674,7 @@ static int rmi_create_function(struct rmi_device *rmi_dev,if(!fn->irq_mask){dev_err(dev,"%s: Failed to create irq_mask for F%02X.\n",__func__,pdt->function_number);-error=-ENOMEM;-gotoerr_free_mem;+return-ENOMEM;}for(i=0;i<fn->num_of_irqs;i++)
@@ -683,7 +682,7 @@ static int rmi_create_function(struct rmi_device *rmi_dev,error=rmi_register_function(fn);if(error)-gotoerr_free_irq_mask;+returnerror;if(pdt->function_number==0x01)data->f01_container=fn;
@@ -691,12 +690,6 @@ static int rmi_create_function(struct rmi_device *rmi_dev,list_add_tail(&fn->node,&data->function_list);returnRMI_SCAN_CONTINUE;--err_free_irq_mask:-kfree(fn->irq_mask);-err_free_mem:-kfree(fn);-returnerror;
Unless you create rmi_allocate_function() and do device initialization
there (so that device and kobject are fully initialized and proper ktype
is assigned so that ->release() is set up) you still need to free memory
here if failure happens before calling rmi_register_function().
Thanks.
--
Dmitry
From: Christopher Heiny <hidden> Date: 2014-02-13 02:31:05
On 02/11/2014 10:49 PM, Dmitry Torokhov wrote:
On Tue, Feb 11, 2014 at 03:13:30PM -0800, Christopher Heiny wrote:
quoted
For rmi_sensor and rmi_function device_types, use put_device() and
the assocated device_type.release() function to clean up related
structures and storage in the correct and safe order.
Signed-off-by: Christopher Heiny <redacted>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Benjamin Tissoires <redacted>
Cc: Linux Walleij <redacted>
Cc: David Herrmann <redacted>
Cc: Jiri Kosina <redacted>
Cc: Courtney Cavin <redacted>
---
drivers/input/rmi4/rmi_bus.c | 65 +++++++++++++++--------------------------
drivers/input/rmi4/rmi_driver.c | 11 ++-----
2 files changed, 25 insertions(+), 51 deletions(-)
This is wrong, rmi_release_function should finish cleaning up resources,
however unregistration part should happen much earlier. If someone takes
reference to the device in debugfs the device may never go away as noone
will kick the user out.
Please put the calls to rmi_function_teardown_debugfs() back where they
originally were.
@@ -674,8 +674,7 @@ static int rmi_create_function(struct rmi_device *rmi_dev,if(!fn->irq_mask){dev_err(dev,"%s: Failed to create irq_mask for F%02X.\n",__func__,pdt->function_number);-error=-ENOMEM;-gotoerr_free_mem;+return-ENOMEM;}for(i=0;i<fn->num_of_irqs;i++)
@@ -683,7 +682,7 @@ static int rmi_create_function(struct rmi_device *rmi_dev,error=rmi_register_function(fn);if(error)-gotoerr_free_irq_mask;+returnerror;if(pdt->function_number==0x01)data->f01_container=fn;
@@ -691,12 +690,6 @@ static int rmi_create_function(struct rmi_device *rmi_dev,list_add_tail(&fn->node,&data->function_list);returnRMI_SCAN_CONTINUE;--err_free_irq_mask:-kfree(fn->irq_mask);-err_free_mem:-kfree(fn);-returnerror;
Unless you create rmi_allocate_function() and do device initialization
there (so that device and kobject are fully initialized and proper ktype
is assigned so that ->release() is set up) you still need to free memory
here if failure happens before calling rmi_register_function().
Hmmm. If we adopt the idea of allocating the irq_mask as an
array in the rmi_function structure, like you did in your
rmi_f01.c patch for the interrupt_enable mask, then there's no
point of failure bewteen allocating the storage and the call to
rmi_register_function(). rmi_register_function() doesn't have a
failure point prior to calling device_register(), and the
put_device() call in there should be able clean things up, like
Courtney proposed.
So making that change, along with some others you and Courtney
have suggested in other emails, we get the patch below.
Chris
--
Input: synaptics-rmi4 - Use put_device() and device_type.release() to
free storage.
From: Christopher Heiny <redacted>
For rmi_sensor and rmi_function device_types, use put_device() and
the assocated device_type.release() function to clean up related
structures and storage in the correct and safe order.
Allocate irq_mask as part of struct rmi_function.
Delete unused rmi_driver_irq_get_mask() function.
Suggested-by: Courtney Cavin <redacted>
Signed-off-by: Christopher Heiny <redacted>
---
drivers/input/rmi4/rmi_bus.c | 17 ++++++++-------
drivers/input/rmi4/rmi_bus.h | 2 +-
drivers/input/rmi4/rmi_driver.c | 46
+++++------------------------------------
3 files changed, 15 insertions(+), 50 deletions(-)
On Wed, Feb 12, 2014 at 06:31:04PM -0800, Christopher Heiny wrote:
quoted hunk
Input: synaptics-rmi4 - Use put_device() and device_type.release()
to free storage.
From: Christopher Heiny <redacted>
For rmi_sensor and rmi_function device_types, use put_device() and
the assocated device_type.release() function to clean up related
structures and storage in the correct and safe order.
Allocate irq_mask as part of struct rmi_function.
Delete unused rmi_driver_irq_get_mask() function.
Suggested-by: Courtney Cavin <redacted>
Signed-off-by: Christopher Heiny <redacted>
---
drivers/input/rmi4/rmi_bus.c | 17 ++++++++-------
drivers/input/rmi4/rmi_bus.h | 2 +-
drivers/input/rmi4/rmi_driver.c | 46
+++++------------------------------------
3 files changed, 15 insertions(+), 50 deletions(-)
@@ -240,16 +243,14 @@ int rmi_register_function(struct rmi_function *fn) dev_err(&rmi_dev->dev, "Failed device_register function device %s\n", dev_name(&fn->dev));- goto error_exit;+ rmi_function_teardown_debugfs(fn);+ put_device(&fn->dev);
This is not proper place to free structures since
rmi_register_function() was not the one that allocated them.
OK, I split the rmi_driver_irq_get_mask() removal into a separate patch
and applied it, this leaves us with the patch below (BTW, your mailed
damaged - line wrapped - the patch so I had to reconstruct it).
I switched from using device_register/device_unregister to
device_initialize/device_add/device_del/put_device as it allows better
control over error unwinding and destroying the objects which is
important if you want to delete debugfs entries once all fucntion
handler have been unregister but before our memory is gone.
Thanks.
--
Dmitry
Input: synaptics-rmi4 - use put_device() to free devices
From: Christopher Heiny <redacted>
For rmi_sensor and rmi_function device_types, use put_device() and
the associated device_type->release() function to clean up related
structures and storage in the correct and safe order.
Allocate irq_mask as part of struct rmi_function.
Suggested-by: Courtney Cavin <redacted>
Signed-off-by: Christopher Heiny <redacted>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/rmi4/rmi_bus.c | 30 +++++++++++++++++++++---------
drivers/input/rmi4/rmi_bus.h | 7 ++++---
drivers/input/rmi4/rmi_driver.c | 25 +++++++------------------
3 files changed, 32 insertions(+), 30 deletions(-)
@@ -617,7 +616,7 @@ static int rmi_initial_reset(struct rmi_device *rmi_dev,}staticintrmi_create_function(structrmi_device*rmi_dev,-void*ctx,conststructpdt_entry*pdt)+void*ctx,conststructpdt_entry*pdt){structdevice*dev=&rmi_dev->dev;structrmi_driver_data*data=dev_get_drvdata(&rmi_dev->dev);
@@ -630,7 +629,9 @@ static int rmi_create_function(struct rmi_device *rmi_dev,dev_dbg(dev,"Initializing F%02X for %s.\n",pdt->function_number,pdata->sensor_name);-fn=kzalloc(sizeof(structrmi_function),GFP_KERNEL);+fn=kzalloc(sizeof(structrmi_function)++BITS_TO_LONGS(data->irq_count)*sizeof(unsignedlong),+GFP_KERNEL);if(!fn){dev_err(dev,"Failed to allocate memory for F%02X\n",pdt->function_number);
@@ -646,22 +647,12 @@ static int rmi_create_function(struct rmi_device *rmi_dev,fn->irq_pos=*current_irq_count;*current_irq_count+=fn->num_of_irqs;-fn->irq_mask=kzalloc(-BITS_TO_LONGS(data->irq_count)*sizeof(unsignedlong),-GFP_KERNEL);-if(!fn->irq_mask){-dev_err(dev,"%s: Failed to create irq_mask for F%02X.\n",-__func__,pdt->function_number);-error=-ENOMEM;-gotoerr_free_mem;-}-for(i=0;i<fn->num_of_irqs;i++)set_bit(fn->irq_pos+i,fn->irq_mask);error=rmi_register_function(fn);if(error)-gotoerr_free_irq_mask;+gotoerr_put_fn;if(pdt->function_number==0x01)data->f01_container=fn;
@@ -670,10 +661,8 @@ static int rmi_create_function(struct rmi_device *rmi_dev,returnRMI_SCAN_CONTINUE;-err_free_irq_mask:-kfree(fn->irq_mask);-err_free_mem:-kfree(fn);+err_put_fn:+put_device(&fn->dev);returnerror;}
From: Courtney Cavin <hidden> Date: 2014-02-13 21:57:46
On Thu, Feb 13, 2014 at 07:15:24AM +0100, Dmitry Torokhov wrote:
On Wed, Feb 12, 2014 at 06:31:04PM -0800, Christopher Heiny wrote:
quoted
Input: synaptics-rmi4 - Use put_device() and device_type.release()
to free storage.
From: Christopher Heiny <redacted>
For rmi_sensor and rmi_function device_types, use put_device() and
the assocated device_type.release() function to clean up related
structures and storage in the correct and safe order.
Allocate irq_mask as part of struct rmi_function.
Delete unused rmi_driver_irq_get_mask() function.
[...]
quoted hunk
Input: synaptics-rmi4 - use put_device() to free devices
From: Christopher Heiny <redacted>
For rmi_sensor and rmi_function device_types, use put_device() and
the associated device_type->release() function to clean up related
structures and storage in the correct and safe order.
Allocate irq_mask as part of struct rmi_function.
Suggested-by: Courtney Cavin <redacted>
Signed-off-by: Christopher Heiny <redacted>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/rmi4/rmi_bus.c | 30 +++++++++++++++++++++---------
drivers/input/rmi4/rmi_bus.h | 7 ++++---
drivers/input/rmi4/rmi_driver.c | 25 +++++++------------------
3 files changed, 32 insertions(+), 30 deletions(-)
On Thu, Feb 13, 2014 at 01:59:31PM -0800, Courtney Cavin wrote:
On Thu, Feb 13, 2014 at 07:15:24AM +0100, Dmitry Torokhov wrote:
quoted
On Wed, Feb 12, 2014 at 06:31:04PM -0800, Christopher Heiny wrote:
quoted
Input: synaptics-rmi4 - Use put_device() and device_type.release()
to free storage.
From: Christopher Heiny <redacted>
For rmi_sensor and rmi_function device_types, use put_device() and
the assocated device_type.release() function to clean up related
structures and storage in the correct and safe order.
Allocate irq_mask as part of struct rmi_function.
Delete unused rmi_driver_irq_get_mask() function.
[...]
quoted
Input: synaptics-rmi4 - use put_device() to free devices
From: Christopher Heiny <redacted>
For rmi_sensor and rmi_function device_types, use put_device() and
the associated device_type->release() function to clean up related
structures and storage in the correct and safe order.
Allocate irq_mask as part of struct rmi_function.
Suggested-by: Courtney Cavin <redacted>
Signed-off-by: Christopher Heiny <redacted>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/rmi4/rmi_bus.c | 30 +++++++++++++++++++++---------
drivers/input/rmi4/rmi_bus.h | 7 ++++---
drivers/input/rmi4/rmi_driver.c | 25 +++++++------------------
3 files changed, 32 insertions(+), 30 deletions(-)
And the chip driver now is expected to know it's a device, and trust
that the bus code knows how to free the memory.
Yeah. That is why for input devices I have a separate
input_allocate_device and input_free_device... But given that RMI is
pretty-much self-contained I think we can live with this.
As this clearly fixes a bug or two, I say we should take this patch
as-is and worry about proper ownership at some other time.
-Courtney
From: Christopher Heiny <hidden> Date: 2014-02-21 23:29:11
Sorry for top posting - using web mail right now.
I think something like allocate_device and free_device will be needed sooner rather than later. I'll get a patch out for that in the next couple of days.
Chris
________________________________________
From: linux-input-owner@vger.kernel.org [linux-input-owner@vger.kernel.org] on behalf of Dmitry Torokhov [dmitry.torokhov@gmail.com]
Sent: Thursday, February 13, 2014 2:10 PM
To: Courtney Cavin
Cc: Christopher Heiny; Linux Input; Andrew Duggan; Vincent Huang; Vivian Ly; Daniel Rosenberg; Jean Delvare; Joerie de Gram; Linus Walleij; Benjamin Tissoires; David Herrmann; Jiri Kosina
Subject: Re: [PATCH] input synaptics-rmi4: Use put_device() and device_type.release() to free storage.
On Thu, Feb 13, 2014 at 01:59:31PM -0800, Courtney Cavin wrote:
On Thu, Feb 13, 2014 at 07:15:24AM +0100, Dmitry Torokhov wrote:
quoted
On Wed, Feb 12, 2014 at 06:31:04PM -0800, Christopher Heiny wrote:
quoted
Input: synaptics-rmi4 - Use put_device() and device_type.release()
to free storage.
From: Christopher Heiny <redacted>
For rmi_sensor and rmi_function device_types, use put_device() and
the assocated device_type.release() function to clean up related
structures and storage in the correct and safe order.
Allocate irq_mask as part of struct rmi_function.
Delete unused rmi_driver_irq_get_mask() function.
[...]
quoted
Input: synaptics-rmi4 - use put_device() to free devices
From: Christopher Heiny <redacted>
For rmi_sensor and rmi_function device_types, use put_device() and
the associated device_type->release() function to clean up related
structures and storage in the correct and safe order.
Allocate irq_mask as part of struct rmi_function.
Suggested-by: Courtney Cavin <redacted>
Signed-off-by: Christopher Heiny <redacted>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/rmi4/rmi_bus.c | 30 +++++++++++++++++++++---------
drivers/input/rmi4/rmi_bus.h | 7 ++++---
drivers/input/rmi4/rmi_driver.c | 25 +++++++------------------
3 files changed, 32 insertions(+), 30 deletions(-)
And the chip driver now is expected to know it's a device, and trust
that the bus code knows how to free the memory.
Yeah. That is why for input devices I have a separate
input_allocate_device and input_free_device... But given that RMI is
pretty-much self-contained I think we can live with this.
As this clearly fixes a bug or two, I say we should take this patch
as-is and worry about proper ownership at some other time.
-Courtney
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html