All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: Allow regulator-regulator supplies to be specified by name
@ 2010-04-26 14:18 Mark Brown
  2010-04-26 14:50 ` Liam Girdwood
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Brown @ 2010-04-26 14:18 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: linux-kernel, Mark Brown

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>
---
 drivers/regulator/core.c          |   30 ++++++++++++++++++++++++++++++
 include/linux/regulator/machine.h |    9 +++++++--
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 51cf2bb..eb112d9 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -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)
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index 234a847..e298028 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -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;
 
-- 
1.7.0.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] regulator: Allow regulator-regulator supplies to be specified by name
  2010-04-26 14:18 [PATCH] regulator: Allow regulator-regulator supplies to be specified by name Mark Brown
@ 2010-04-26 14:50 ` Liam Girdwood
  0 siblings, 0 replies; 2+ messages in thread
From: Liam Girdwood @ 2010-04-26 14:50 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel

On Mon, 2010-04-26 at 15:18 +0100, Mark Brown wrote:
> 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>

Applied.

Thanks

Liam

-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-26 14:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-26 14:18 [PATCH] regulator: Allow regulator-regulator supplies to be specified by name Mark Brown
2010-04-26 14:50 ` Liam Girdwood

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.