diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2012-07-05 02:19:42 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-07-05 08:15:40 -0400 |
commit | e2c98eaf928a2a0ecaca1db9aa5dc56a36699d9f (patch) | |
tree | 705a66684c47b0f807ab652c7504d93f2db7edc2 | |
parent | e113d792d56d4b720b3d84c122b6af84c3bfa094 (diff) |
regulator: core: remove sysfs entry properly in regulator_put
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>
-rw-r--r-- | drivers/regulator/core.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index f98a8ee29933..974276afd1f0 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -1063,6 +1063,8 @@ static struct regulator *create_regulator(struct regulator_dev *rdev, | |||
1063 | list_add(®ulator->list, &rdev->consumer_list); | 1063 | list_add(®ulator->list, &rdev->consumer_list); |
1064 | 1064 | ||
1065 | if (dev) { | 1065 | if (dev) { |
1066 | regulator->dev = dev; | ||
1067 | |||
1066 | /* Add a link to the device sysfs entry */ | 1068 | /* Add a link to the device sysfs entry */ |
1067 | size = scnprintf(buf, REG_STR_SIZE, "%s-%s", | 1069 | size = scnprintf(buf, REG_STR_SIZE, "%s-%s", |
1068 | dev->kobj.name, supply_name); | 1070 | dev->kobj.name, supply_name); |
@@ -1359,11 +1361,8 @@ void regulator_put(struct regulator *regulator) | |||
1359 | debugfs_remove_recursive(regulator->debugfs); | 1361 | debugfs_remove_recursive(regulator->debugfs); |
1360 | 1362 | ||
1361 | /* remove any sysfs entries */ | 1363 | /* remove any sysfs entries */ |
1362 | if (regulator->dev) { | 1364 | if (regulator->dev) |
1363 | sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name); | 1365 | sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name); |
1364 | device_remove_file(regulator->dev, ®ulator->dev_attr); | ||
1365 | kfree(regulator->dev_attr.attr.name); | ||
1366 | } | ||
1367 | kfree(regulator->supply_name); | 1366 | kfree(regulator->supply_name); |
1368 | list_del(®ulator->list); | 1367 | list_del(®ulator->list); |
1369 | kfree(regulator); | 1368 | kfree(regulator); |