Commit f0879217 authored by Eva Rachel Retuya's avatar Eva Rachel Retuya Committed by Jonathan Cameron

staging: iio: ad7606: rework regulator handling

Currently, this driver ignores all errors from regulator_get(). The way
it is now, it also breaks probe deferral (EPROBE_DEFER). The correct
behavior is to propagate the error to the upper layers so they can
handle it accordingly.

Rework the regulator handling so that it matches the standard behavior.
If the specific design uses a static always-on regulator and does not
explicitly specify it, regulator_get() will return the dummy regulator.
Suggested-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarEva Rachel Retuya <eraretuya@gmail.com>
Acked-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 12edb974
......@@ -425,9 +425,12 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
INIT_WORK(&st->poll_work, &ad7606_poll_bh_to_ring);
st->reg = devm_regulator_get(dev, "avcc");
if (!IS_ERR(st->reg)) {
if (IS_ERR(st->reg))
return PTR_ERR(st->reg);
ret = regulator_enable(st->reg);
if (ret)
if (ret) {
dev_err(dev, "Failed to enable specified AVcc supply\n");
return ret;
}
......@@ -484,7 +487,6 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
free_irq(irq, indio_dev);
error_disable_reg:
if (!IS_ERR(st->reg))
regulator_disable(st->reg);
return ret;
}
......@@ -499,7 +501,6 @@ int ad7606_remove(struct device *dev, int irq)
iio_triggered_buffer_cleanup(indio_dev);
free_irq(irq, indio_dev);
if (!IS_ERR(st->reg))
regulator_disable(st->reg);
return 0;
......
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