From: David Brownell Date: Wed, 31 Dec 2008 12:54:19 +0000 (+0000) Subject: regulator: catch some registration errors X-Git-Tag: v2.6.29-rc1~44^2~1 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=6001e13c5f708eb68c744a69df3c2c281156030d;p=linux-2.6-omap-h63xx.git 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 Signed-off-by: Mark Brown Signed-off-by: Liam Girdwood --- diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 7341c97cd91..f511a406fca 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, if (supply == NULL) return -EINVAL; + list_for_each_entry(node, ®ulator_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;