diff mbox

regulator: core: remove sysfs entry properly in regulator_put

Message ID 1341469182-5079-1-git-send-email-shawn.guo@linaro.org
State New, archived
Headers show

Commit Message

Shawn Guo July 5, 2012, 6:19 a.m. UTC
With changes introduced by commit 222cc7b (regulator: core: Allow
multiple requests of a single supply mapping) on create_regulator,
regulator_put needs a corresponding update on sysfs entry removing.

Also regulator->dev still needs to get assigned in create_regulator,
otherwise, sysfs_remove_link call in regulator_put will get bypassed.

Reported-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/regulator/core.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

Comments

Dong Aisheng July 5, 2012, 8:28 a.m. UTC | #1
On Thu, Jul 05, 2012 at 02:19:42PM +0800, Shawn Guo wrote:
> With changes introduced by commit 222cc7b (regulator: core: Allow
> multiple requests of a single supply mapping) on create_regulator,
> regulator_put needs a corresponding update on sysfs entry removing.
> 
> Also regulator->dev still needs to get assigned in create_regulator,
> otherwise, sysfs_remove_link call in regulator_put will get bypassed.
> 
> Reported-by: Fabio Estevam <festevam@gmail.com>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/regulator/core.c |    7 +++----
>  1 files changed, 3 insertions(+), 4 deletions(-)
> 
Good catch.

Tested-by: Dong Aisheng <dong.aisheng@linaro.org>
Acked-by: Dong Aisheng <dong.aisheng@linaro.org>

Regards
Dong Aisheng
Mark Brown July 5, 2012, 12:15 p.m. UTC | #2
On Thu, Jul 05, 2012 at 02:19:42PM +0800, Shawn Guo wrote:
> With changes introduced by commit 222cc7b (regulator: core: Allow
> multiple requests of a single supply mapping) on create_regulator,
> regulator_put needs a corresponding update on sysfs entry removing.
> 
> Also regulator->dev still needs to get assigned in create_regulator,
> otherwise, sysfs_remove_link call in regulator_put will get bypassed.

Applied, but you should really know better than to submit two separate
changes in a single patch.
diff mbox

Patch

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index ef07b62..3998d8f 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1071,6 +1071,8 @@  static struct regulator *create_regulator(struct regulator_dev *rdev,
 	list_add(&regulator->list, &rdev->consumer_list);
 
 	if (dev) {
+		regulator->dev = dev;
+
 		/* Add a link to the device sysfs entry */
 		size = scnprintf(buf, REG_STR_SIZE, "%s-%s",
 				 dev->kobj.name, supply_name);
@@ -1367,11 +1369,8 @@  void regulator_put(struct regulator *regulator)
 	debugfs_remove_recursive(regulator->debugfs);
 
 	/* remove any sysfs entries */
-	if (regulator->dev) {
+	if (regulator->dev)
 		sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name);
-		device_remove_file(regulator->dev, &regulator->dev_attr);
-		kfree(regulator->dev_attr.attr.name);
-	}
 	kfree(regulator->supply_name);
 	list_del(&regulator->list);
 	kfree(regulator);