Skip to content

Commit e2c98ea

Browse files
Shawn Guobroonie
authored andcommitted
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>
1 parent e113d79 commit e2c98ea

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎drivers/regulator/core.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,8 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
10631063
list_add(&regulator->list, &rdev->consumer_list);
10641064

10651065
if (dev) {
1066+
regulator->dev = dev;
1067+
10661068
/* Add a link to the device sysfs entry */
10671069
size = scnprintf(buf, REG_STR_SIZE, "%s-%s",
10681070
dev->kobj.name, supply_name);
@@ -1359,11 +1361,8 @@ void regulator_put(struct regulator *regulator)
13591361
debugfs_remove_recursive(regulator->debugfs);
13601362

13611363
/* remove any sysfs entries */
1362-
if (regulator->dev) {
1364+
if (regulator->dev)
13631365
sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name);
1364-
device_remove_file(regulator->dev, &regulator->dev_attr);
1365-
kfree(regulator->dev_attr.attr.name);
1366-
}
13671366
kfree(regulator->supply_name);
13681367
list_del(&regulator->list);
13691368
kfree(regulator);

0 commit comments

Comments
 (0)