Skip to contentSkip to conversation

regulator: gpio: Don't require a regulator-type property

PATCH In review Mark Brown 2 participants 3 messages Dec 5, 2013 Voltage and current regulator framework

lore
Share & tools
lore

Mark Brown

author maintainer
#0 lore raw

PATCH 1/1 regulator: gpio: Don't require a regulator-type property

From: Mark Brown <[email protected]>

Since essentially all GPIO controlled regulators are voltage regulators make the regulator-type property optional, defaulting to voltage.

---

Compile tested only.

 drivers/regulator/gpio-regulator.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/regulator/gpio-regulator.c +6 -8
index 234960dc9607..13ec94d984ca 100644
@@ -203,17 +203,15 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
 	}
 	config->nr_states = i;
 
+	config->type = REGULATOR_VOLTAGE;
 	ret = of_property_read_string(np, "regulator-type", &regtype);
-	if (ret < 0) {
-		dev_err(dev, "Missing 'regulator-type' property\n");
-		return ERR_PTR(-EINVAL);
+	if (ret >= 0) {
+		if (!strncmp("voltage", regtype, 7))
+			config->type = REGULATOR_VOLTAGE;
+		else if (!strncmp("current", regtype, 7))
+			config->type = REGULATOR_CURRENT;
 	}
 
-	if (!strncmp("voltage", regtype, 7))
-		config->type = REGULATOR_VOLTAGE;
-	else if (!strncmp("current", regtype, 7))
-		config->type = REGULATOR_CURRENT;
-
 	return config;
 }
 
Signature · 1 line
1.8.5.1
#1 lore raw

Hi Mark,

Thanks for the patch.

Quoted 22 lines · On Thursday 05 December 2013 00:31:55 Mark Brown wrote:

From: Mark Brown <[email protected]>

Since essentially all GPIO controlled regulators are voltage regulators make the regulator-type property optional, defaulting to voltage.

---

Compile tested only.

 drivers/regulator/gpio-regulator.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
(quoted diff) +0 -0

b/drivers/regulator/gpio-regulator.c index 234960dc9607..13ec94d984ca 100644

drivers/regulator/gpio-regulator.c +0 -0
@@ -203,17 +203,15 @@ of_get_gpio_regulator_config(struct device *dev,
 struct device_node *np) }
 	config->nr_states = i;
 

drivers/regulator/gpio-regulator.c of_get_gpio_regulator_config(struct device *dev, · line 212

Quoted 10 lines
drivers/regulator/gpio-regulator.c +6 -3
+	config->type = REGULATOR_VOLTAGE;
 	ret = of_property_read_string(np, "regulator-type", &regtype);
-	if (ret < 0) {
-		dev_err(dev, "Missing 'regulator-type' property\n");
-		return ERR_PTR(-EINVAL);
+	if (ret >= 0) {
+		if (!strncmp("voltage", regtype, 7))
+			config->type = REGULATOR_VOLTAGE;
+		else if (!strncmp("current", regtype, 7))
+			config->type = REGULATOR_CURRENT;

Should we warn or error in case of an unsupported value ?

Quoted 9 lines
drivers/regulator/gpio-regulator.c +0 -5
 	}
 
-	if (!strncmp("voltage", regtype, 7))
-		config->type = REGULATOR_VOLTAGE;
-	else if (!strncmp("current", regtype, 7))
-		config->type = REGULATOR_CURRENT;
-
 	return config;
 }
Signature · 3 lines
Regards,

Laurent Pinchart
author maintainer
#2 lore raw
Quoted 9 lines · Laurent Pinchart

drivers/regulator/gpio-regulator.c of_get_gpio_regulator_config(struct device *dev, struct device_node *np) · line 212

Quoted 5 lines · On Thursday 05 December 2013 00:31:55 Mark Brown wrote:
drivers/regulator/gpio-regulator.c +5 -0
+	if (ret >= 0) {
+		if (!strncmp("voltage", regtype, 7))
+			config->type = REGULATOR_VOLTAGE;
+		else if (!strncmp("current", regtype, 7))
+			config->type = REGULATOR_CURRENT;

Should we warn or error in case of an unsupported value ?

That's sensible, yes - this was just a straight change to make the property optional. Given that we've always accepted anything a warning seems more appropriate otherwise we might break existing DTs with typos or something.