regulator: catch some registration errors
[safe/jmp/linux-2.6] / drivers / regulator / core.c
index fda4400..f511a40 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;
@@ -1012,10 +1026,12 @@ static int _regulator_enable(struct regulator_dev *rdev)
  * regulator_enable - enable regulator output
  * @regulator: regulator source
  *
- * Enable the regulator output at the predefined voltage or current value.
+ * Request that the regulator be enabled with the regulator output at
+ * the predefined voltage or current value.  Calls to regulator_enable()
+ * must be balanced with calls to regulator_disable().
+ *
  * NOTE: the output value can be set by other drivers, boot loader or may be
- * hardwired in the regulator.  Calls to regulator_enable() must be balanced
- * with calls to regulator_disable().
+ * hardwired in the regulator.
  */
 int regulator_enable(struct regulator *regulator)
 {
@@ -1073,11 +1089,13 @@ static int _regulator_disable(struct regulator_dev *rdev)
  * regulator_disable - disable regulator output
  * @regulator: regulator source
  *
- * Disable the regulator output voltage or current.
+ * Disable the regulator output voltage or current.  Calls to
+ * regulator_enable() must be balanced with calls to
+ * regulator_disable().
  *
  * NOTE: this will only disable the regulator output if no other consumer
- * devices have it enabled.  Calls to regulator_enable() must be balanced with
- * calls to regulator_disable().
+ * devices have it enabled, the regulator device supports disabling and
+ * machine constraints permit this operation.
  */
 int regulator_disable(struct regulator *regulator)
 {
@@ -1936,7 +1954,7 @@ void regulator_unregister(struct regulator_dev *rdev)
 EXPORT_SYMBOL_GPL(regulator_unregister);
 
 /**
- * regulator_suspend_prepare: prepare regulators for system wide suspend
+ * regulator_suspend_prepare - prepare regulators for system wide suspend
  * @state: system suspend state
  *
  * Configure each regulator with it's suspend operating parameters for state.