]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/regulator/core.c
regulator: catch some registration errors
[linux-2.6-omap-h63xx.git] / drivers / regulator / core.c
index 7341c97cd916d607766cec32bf1d45ae04e34062..f511a406fcaac4fca414bb954124d3e11f55cc86 100644 (file)
@@ -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;