diff options
author | Alexandru Ardelean <alexandru.ardelean@analog.com> | 2020-10-01 16:10:48 +0200 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2020-10-10 19:01:26 +0200 |
commit | 28963f2f6b46d75bda8fed15bd5ce9923427a40d (patch) | |
tree | f5d2c186854d06b032f430d1a50101cf7fee7bfa /drivers/iio/adc | |
parent | iio: core: Fix IIO_VAL_FRACTIONAL calculation for negative values (diff) | |
download | linux-28963f2f6b46d75bda8fed15bd5ce9923427a40d.tar.xz linux-28963f2f6b46d75bda8fed15bd5ce9923427a40d.zip |
iio: adc: ad7298: rework external ref setup & remove platform data
This change removes the old platform data for ad7298. It is only used to
provide whether to use an external regulator as a reference.
So, the logic is inverted a bit. The driver now tries to obtain a
regulator. If one is provided, then the external ref is used. The rest of
the logic should work as before.
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20201001141048.69050-1-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/adc')
-rw-r--r-- | drivers/iio/adc/ad7298.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c index 48d43cb0f932..fa1047f74a1f 100644 --- a/drivers/iio/adc/ad7298.c +++ b/drivers/iio/adc/ad7298.c @@ -23,8 +23,6 @@ #include <linux/iio/trigger_consumer.h> #include <linux/iio/triggered_buffer.h> -#include <linux/platform_data/ad7298.h> - #define AD7298_WRITE BIT(15) /* write to the control register */ #define AD7298_REPEAT BIT(14) /* repeated conversion enable */ #define AD7298_CH(x) BIT(13 - (x)) /* channel select */ @@ -283,7 +281,6 @@ static const struct iio_info ad7298_info = { static int ad7298_probe(struct spi_device *spi) { - struct ad7298_platform_data *pdata = spi->dev.platform_data; struct ad7298_state *st; struct iio_dev *indio_dev; int ret; @@ -294,14 +291,18 @@ static int ad7298_probe(struct spi_device *spi) st = iio_priv(indio_dev); - if (pdata && pdata->ext_ref) + st->reg = devm_regulator_get_optional(&spi->dev, "vref"); + if (!IS_ERR(st->reg)) { st->ext_ref = AD7298_EXTREF; + } else { + ret = PTR_ERR(st->reg); + if (ret != -ENODEV) + return ret; - if (st->ext_ref) { - st->reg = devm_regulator_get(&spi->dev, "vref"); - if (IS_ERR(st->reg)) - return PTR_ERR(st->reg); + st->reg = NULL; + } + if (st->reg) { ret = regulator_enable(st->reg); if (ret) return ret; |