summaryrefslogtreecommitdiffstats
path: root/kernel/drivers/iio/adc/ad7266.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/drivers/iio/adc/ad7266.c')
-rw-r--r--kernel/drivers/iio/adc/ad7266.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/kernel/drivers/iio/adc/ad7266.c b/kernel/drivers/iio/adc/ad7266.c
index 21e19b60e..2123f0ac2 100644
--- a/kernel/drivers/iio/adc/ad7266.c
+++ b/kernel/drivers/iio/adc/ad7266.c
@@ -396,8 +396,8 @@ static int ad7266_probe(struct spi_device *spi)
st = iio_priv(indio_dev);
- st->reg = devm_regulator_get(&spi->dev, "vref");
- if (!IS_ERR_OR_NULL(st->reg)) {
+ st->reg = devm_regulator_get_optional(&spi->dev, "vref");
+ if (!IS_ERR(st->reg)) {
ret = regulator_enable(st->reg);
if (ret)
return ret;
@@ -408,6 +408,9 @@ static int ad7266_probe(struct spi_device *spi)
st->vref_mv = ret / 1000;
} else {
+ /* Any other error indicates that the regulator does exist */
+ if (PTR_ERR(st->reg) != -ENODEV)
+ return PTR_ERR(st->reg);
/* Use internal reference */
st->vref_mv = 2500;
}