Skip to content

Commit

Permalink
regulator: add unset_regulator_supplies to fix regulator_unregister
Browse files Browse the repository at this point in the history
Currently regulator_unregister does not clear regulator <--> consumer
mapping.
This patch introduces unset_regulator_supplies that clear the map.

Signed-off-by: Mike Rapoport <mike@compulab.co.il>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
  • Loading branch information
Mike Rapoport authored and Liam Girdwood committed Mar 31, 2009
1 parent 90ca563 commit 0f1d747
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,19 @@ static void unset_consumer_device_supply(struct regulator_dev *rdev,
}
}

static void unset_regulator_supplies(struct regulator_dev *rdev)
{
struct regulator_map *node, *n;

list_for_each_entry_safe(node, n, &regulator_map_list, list) {
if (rdev == node->regulator) {
list_del(&node->list);
kfree(node);
return;
}
}
}

#define REG_STR_SIZE 32

static struct regulator *create_regulator(struct regulator_dev *rdev,
Expand Down Expand Up @@ -1970,6 +1983,7 @@ void regulator_unregister(struct regulator_dev *rdev)
return;

mutex_lock(&regulator_list_mutex);
unset_regulator_supplies(rdev);
list_del(&rdev->list);
if (rdev->supply)
sysfs_remove_link(&rdev->dev.kobj, "supply");
Expand Down

0 comments on commit 0f1d747

Please sign in to comment.