]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
regulator: Allow regulator-regulator supplies to be specified by name
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 26 Apr 2010 14:18:14 +0000 (15:18 +0100)
committerLiam Girdwood <lrg@slimlogic.co.uk>
Tue, 25 May 2010 09:16:01 +0000 (10:16 +0100)
When one regulator supplies another allow the relationship to be specified
using names rather than struct regulators, in a similar manner to that
allowed for consumer supplies. This allows static configuration at compile
time, reducing the need for dynamic init code.

Also change the references to LINE supply to be system supply since line
is sometimes used for actual supplies and therefore potentially confusing.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
drivers/regulator/core.c
include/linux/regulator/machine.h

index 51cf2bb37438d92f9711bb385fde0f642e663c48..eb112d9615150e6611c5d8e3eda6f38dfb737fc6 100644 (file)
@@ -2328,7 +2328,37 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
                goto scrub;
 
        /* set supply regulator if it exists */
+       if (init_data->supply_regulator && init_data->supply_regulator_dev) {
+               dev_err(dev,
+                       "Supply regulator specified by both name and dev\n");
+               goto scrub;
+       }
+
+       if (init_data->supply_regulator) {
+               struct regulator_dev *r;
+               int found = 0;
+
+               list_for_each_entry(r, &regulator_list, list) {
+                       if (strcmp(rdev_get_name(r),
+                                  init_data->supply_regulator) == 0) {
+                               found = 1;
+                               break;
+                       }
+               }
+
+               if (!found) {
+                       dev_err(dev, "Failed to find supply %s\n",
+                               init_data->supply_regulator);
+                       goto scrub;
+               }
+
+               ret = set_supply(rdev, r);
+               if (ret < 0)
+                       goto scrub;
+       }
+
        if (init_data->supply_regulator_dev) {
+               dev_warn(dev, "Uses supply_regulator_dev instead of regulator_supply\n");
                ret = set_supply(rdev,
                        dev_get_drvdata(init_data->supply_regulator_dev));
                if (ret < 0)
index 234a8476cba8a5acadb627236819e89333838eec..e2980287245e8cb28275dae09fcc33373fa6c538 100644 (file)
@@ -157,7 +157,11 @@ struct regulator_consumer_supply {
  *
  * Initialisation constraints, our supply and consumers supplies.
  *
- * @supply_regulator_dev: Parent regulator (if any).
+ * @supply_regulator: Parent regulator.  Specified using the regulator name
+ *                    as it appears in the name field in sysfs, which can
+ *                    be explicitly set using the constraints field 'name'.
+ * @supply_regulator_dev: Parent regulator (if any) - DEPRECATED in favour
+ *                        of supply_regulator.
  *
  * @constraints: Constraints.  These must be specified for the regulator to
  *               be usable.
@@ -168,7 +172,8 @@ struct regulator_consumer_supply {
  * @driver_data: Data passed to regulator_init.
  */
 struct regulator_init_data {
-       struct device *supply_regulator_dev; /* or NULL for LINE */
+       const char *supply_regulator;        /* or NULL for system supply */
+       struct device *supply_regulator_dev; /* or NULL for system supply */
 
        struct regulation_constraints constraints;