Skip to content

Commit

Permalink
regulator: core: remove sysfs entry properly in regulator_put
Browse files Browse the repository at this point in the history
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>
Tested-by: Dong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Shawn Guo authored and Mark Brown committed Jul 5, 2012
1 parent e113d79 commit e2c98ea
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,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);
Expand Down Expand Up @@ -1359,11 +1361,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);
Expand Down

0 comments on commit e2c98ea

Please sign in to comment.