Skip to content

Commit

Permalink
regulator: catch some registration errors
Browse files Browse the repository at this point in the history
Prevent registration of duplicate "struct regulator" names.
They'd be unavailable, and clearly indicate something wrong.

[Edited to remove check for NULL consumer device until we have a
solution for things like cpufreq -- broonie]

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
  • Loading branch information
David Brownell authored and Liam Girdwood committed Jan 8, 2009
1 parent 9fe5817 commit 6001e13
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
@@ -776,6 +776,20 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
if (supply == NULL)
return -EINVAL;

list_for_each_entry(node, &regulator_map_list, list) {
if (consumer_dev != node->dev)
continue;
if (strcmp(node->supply, supply) != 0)
continue;

dev_dbg(consumer_dev, "%s/%s is '%s' supply; fail %s/%s\n",
dev_name(&node->regulator->dev),
node->regulator->desc->name,
supply,
dev_name(&rdev->dev), rdev->desc->name);
return -EBUSY;
}

node = kmalloc(sizeof(struct regulator_map), GFP_KERNEL);
if (node == NULL)
return -ENOMEM;

0 comments on commit 6001e13

Please sign in to comment.