Commit aeb55fff authored by Linus Walleij's avatar Linus Walleij Committed by Jonathan Cameron

iio: st_sensors: fetch and enable regulators unconditionally

These sensors all have Vdd and Vdd_IO lines. This means the
supplies are *not* optional (optional means that the supply is
optional in the electrical sense, not the software sense)
so we need to get the and enable them at all times.

If the device tree or board file does not define suitable
regulators for the component, it will be substituted by a
dummy regulator, or, if regulators are disabled altogether,
by stubs. There is no need to use the IS_ERR_OR_NULL() check
that is considered harmful.

Cc: Giuseppe Barba <giuseppe.barba@st.com>
Cc: Denis Ciocca <denis.ciocca@st.com>
Cc: Crestez Dan Leonard <leonard.crestez@intel.com>
Cc: Gregor Boirie <gregor.boirie@parrot.com>
Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 7f270bc9
...@@ -234,39 +234,35 @@ int st_sensors_power_enable(struct iio_dev *indio_dev) ...@@ -234,39 +234,35 @@ int st_sensors_power_enable(struct iio_dev *indio_dev)
int err; int err;
/* Regulators not mandatory, but if requested we should enable them. */ /* Regulators not mandatory, but if requested we should enable them. */
pdata->vdd = devm_regulator_get_optional(indio_dev->dev.parent, "vdd"); pdata->vdd = devm_regulator_get(indio_dev->dev.parent, "vdd");
if (!IS_ERR(pdata->vdd)) { if (IS_ERR(pdata->vdd)) {
err = regulator_enable(pdata->vdd); dev_err(&indio_dev->dev, "unable to get Vdd supply\n");
if (err != 0) { return PTR_ERR(pdata->vdd);
dev_warn(&indio_dev->dev, }
"Failed to enable specified Vdd supply\n"); err = regulator_enable(pdata->vdd);
return err; if (err != 0) {
} dev_warn(&indio_dev->dev,
} else { "Failed to enable specified Vdd supply\n");
err = PTR_ERR(pdata->vdd); return err;
if (err != -ENODEV)
return err;
} }
pdata->vdd_io = devm_regulator_get_optional(indio_dev->dev.parent, "vddio"); pdata->vdd_io = devm_regulator_get(indio_dev->dev.parent, "vddio");
if (!IS_ERR(pdata->vdd_io)) { if (IS_ERR(pdata->vdd)) {
err = regulator_enable(pdata->vdd_io); dev_err(&indio_dev->dev, "unable to get Vdd_IO supply\n");
if (err != 0) { err = PTR_ERR(pdata->vdd);
dev_warn(&indio_dev->dev, goto st_sensors_disable_vdd;
"Failed to enable specified Vdd_IO supply\n"); }
goto st_sensors_disable_vdd; err = regulator_enable(pdata->vdd_io);
} if (err != 0) {
} else { dev_warn(&indio_dev->dev,
err = PTR_ERR(pdata->vdd_io); "Failed to enable specified Vdd_IO supply\n");
if (err != -ENODEV) goto st_sensors_disable_vdd;
goto st_sensors_disable_vdd;
} }
return 0; return 0;
st_sensors_disable_vdd: st_sensors_disable_vdd:
if (!IS_ERR_OR_NULL(pdata->vdd)) regulator_disable(pdata->vdd);
regulator_disable(pdata->vdd);
return err; return err;
} }
EXPORT_SYMBOL(st_sensors_power_enable); EXPORT_SYMBOL(st_sensors_power_enable);
...@@ -275,11 +271,8 @@ void st_sensors_power_disable(struct iio_dev *indio_dev) ...@@ -275,11 +271,8 @@ void st_sensors_power_disable(struct iio_dev *indio_dev)
{ {
struct st_sensor_data *pdata = iio_priv(indio_dev); struct st_sensor_data *pdata = iio_priv(indio_dev);
if (!IS_ERR_OR_NULL(pdata->vdd)) regulator_disable(pdata->vdd);
regulator_disable(pdata->vdd); regulator_disable(pdata->vdd_io);
if (!IS_ERR_OR_NULL(pdata->vdd_io))
regulator_disable(pdata->vdd_io);
} }
EXPORT_SYMBOL(st_sensors_power_disable); EXPORT_SYMBOL(st_sensors_power_disable);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment