Skip to contentSkip to conversation

iio: max1363: Use devm_regulator_get_optional for optional regulator

PATCH In review Guenter Roeck 2 participants 2 messages Jan 27, 2014 – Feb 8, 2014 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: max1363: Use devm_regulator_get_optional for optional regulator

In kernel version 3.13, devm_regulator_get() may return no error if a regulator is undeclared. regulator_get_voltage() will return -EINVAL if this happens. This causes the driver to fail loading if the vref regulator is not declared.

Since vref is optional, call devm_regulator_get_optional instead.

---
Should be a candidate for -stable (v3.12+).

 drivers/iio/adc/max1363.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/max1363.c +1 -1
index e283f2f..3602592 100644
@@ -1560,7 +1560,7 @@ static int max1363_probe(struct i2c_client *client,
 	st->client = client;
 
 	st->vref_uv = st->chip_info->int_vref_mv * 1000;
-	vref = devm_regulator_get(&client->dev, "vref");
+	vref = devm_regulator_get_optional(&client->dev, "vref");
 	if (!IS_ERR(vref)) {
 		int vref_uv;
 
Signature · 1 line
1.7.9.7
maintainer
#1 lore raw
Quoted 8 lines · Guenter Roeck

In kernel version 3.13, devm_regulator_get() may return no error if a regulator is undeclared. regulator_get_voltage() will return -EINVAL if this happens. This causes the driver to fail loading if the vref regulator is not declared.

Since vref is optional, call devm_regulator_get_optional instead.

Applied and marked for stable.

Thanks,

Quoted 20 lines

---
Should be a candidate for -stable (v3.12+).

  drivers/iio/adc/max1363.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/max1363.c +1 -1
index e283f2f..3602592 100644
@@ -1560,7 +1560,7 @@ static int max1363_probe(struct i2c_client *client,
  	st->client = client;
 
  	st->vref_uv = st->chip_info->int_vref_mv * 1000;
-	vref = devm_regulator_get(&client->dev, "vref");
+	vref = devm_regulator_get_optional(&client->dev, "vref");
  	if (!IS_ERR(vref)) {
  		int vref_uv;