aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2008-12-31 07:54:19 -0500
committerLiam Girdwood <lrg@slimlogic.co.uk>2009-01-08 15:10:34 -0500
commit6001e13c5f708eb68c744a69df3c2c281156030d (patch)
treeff75cc5f48cf3d094ac65d27428b9f2fc176d2e0 /drivers/regulator
parent9fe5817f196054142b9a13ed78c73b76a29f2ea3 (diff)
regulator: catch some registration errors
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>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/core.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 7341c97cd916..f511a406fcaa 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -776,6 +776,20 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
776 if (supply == NULL) 776 if (supply == NULL)
777 return -EINVAL; 777 return -EINVAL;
778 778
779 list_for_each_entry(node, &regulator_map_list, list) {
780 if (consumer_dev != node->dev)
781 continue;
782 if (strcmp(node->supply, supply) != 0)
783 continue;
784
785 dev_dbg(consumer_dev, "%s/%s is '%s' supply; fail %s/%s\n",
786 dev_name(&node->regulator->dev),
787 node->regulator->desc->name,
788 supply,
789 dev_name(&rdev->dev), rdev->desc->name);
790 return -EBUSY;
791 }
792
779 node = kmalloc(sizeof(struct regulator_map), GFP_KERNEL); 793 node = kmalloc(sizeof(struct regulator_map), GFP_KERNEL);
780 if (node == NULL) 794 if (node == NULL)
781 return -ENOMEM; 795 return -ENOMEM;