iio: fetch and enable regulators unconditionally

This patch is inspired by a comment of Jonathan Cameron on patch of
Linus Walleij commit aeb55fff38 ("iio: st_sensors: fetch and enable regulators unconditionally").

The explanation for this change is same as in that patch:
"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.

Reported-by: Linus Wallerij <linus.walleij@linaro.org>
Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Crt Mori <cmo@melexis.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
Crt Mori 2016-09-05 11:14:48 +02:00 committed by Jonathan Cameron
parent 70e483487d
commit 6751607488

View File

@ -416,7 +416,6 @@ static int ms5611_init(struct iio_dev *indio_dev)
return 0;
err_regulator_disable:
if (!IS_ERR_OR_NULL(st->vdd))
regulator_disable(st->vdd);
return ret;
}
@ -425,7 +424,6 @@ static void ms5611_fini(const struct iio_dev *indio_dev)
{
const struct ms5611_state *st = iio_priv(indio_dev);
if (!IS_ERR_OR_NULL(st->vdd))
regulator_disable(st->vdd);
}