Skip to contentSkip to conversation

regulator: core: don't require a supply when supply_name is specified

PATCH In review Andrew Bresticker 2 participants 2 messages Apr 4, 2013 – Apr 5, 2013 Voltage and current regulator framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 regulator: core: don't require a supply when supply_name is specified

Regulator drivers may specify regulator_desc->supply_name which regulator_register() will use to find the supply node for a regulator. If no supply was specified in the device tree or the supply has yet to be registered regulator_register() will fail, deferring the probe of the regulator. In the case where no supply node was specified in the device tree, there is no supply and it is pointless to try and find one later, so go ahead and add the regulator without the supply.

---
 drivers/regulator/core.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/regulator/core.c +9 -1
index a95096e..6267f1c 100644
@@ -3476,7 +3476,14 @@ regulator_register(const struct regulator_desc *regulator_desc,
 
 		r = regulator_dev_lookup(dev, supply, &ret);
 
-		if (!r) {
+		if (ret == -ENODEV) {
+			/*
+			 * No supply was specified for this regulator and
+			 * there will never be one.
+			 */
+			ret = 0;
+			goto add_dev;
+		} else if (!r) {
 			dev_err(dev, "Failed to find supply %s\n", supply);
 			ret = -EPROBE_DEFER;
 			goto scrub;
@@ -3494,6 +3501,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
 		}
 	}
 
+add_dev:
 	/* add consumers devices */
 	if (init_data) {
 		for (i = 0; i < init_data->num_consumer_supplies; i++) {
Signature · 1 line
1.8.1.3
#1 lore raw
Quoted 7 lines · Andrew Bresticker

Regulator drivers may specify regulator_desc->supply_name which regulator_register() will use to find the supply node for a regulator. If no supply was specified in the device tree or the supply has yet to be registered regulator_register() will fail, deferring the probe of the regulator. In the case where no supply node was specified in the device tree, there is no supply and it is pointless to try and find one later, so go ahead and add the regulator without the supply.

I'd call this a broken device tree to be honest, the regulators ought to have a supply specified. We should complain about it. We probably ought to be doing this though so I'll apply.