linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: adc: ad7298: rework external ref setup & remove platform data
@ 2020-10-01 14:10 Alexandru Ardelean
  2020-10-10 17:01 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Alexandru Ardelean @ 2020-10-01 14:10 UTC (permalink / raw)
  To: linux-kernel, linux-iio; +Cc: jic23, Alexandru Ardelean

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>
---
 drivers/iio/adc/ad7298.c             | 17 +++++++++--------
 include/linux/platform_data/ad7298.h | 19 -------------------
 2 files changed, 9 insertions(+), 27 deletions(-)
 delete mode 100644 include/linux/platform_data/ad7298.h

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;
diff --git a/include/linux/platform_data/ad7298.h b/include/linux/platform_data/ad7298.h
deleted file mode 100644
index 3e0ffe2d5d3d..000000000000
--- a/include/linux/platform_data/ad7298.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * AD7298 SPI ADC driver
- *
- * Copyright 2011 Analog Devices Inc.
- */
-
-#ifndef __LINUX_PLATFORM_DATA_AD7298_H__
-#define __LINUX_PLATFORM_DATA_AD7298_H__
-
-/**
- * struct ad7298_platform_data - Platform data for the ad7298 ADC driver
- * @ext_ref: Whether to use an external reference voltage.
- **/
-struct ad7298_platform_data {
-	bool ext_ref;
-};
-
-#endif /* IIO_ADC_AD7298_H_ */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio: adc: ad7298: rework external ref setup & remove platform data
  2020-10-01 14:10 [PATCH] iio: adc: ad7298: rework external ref setup & remove platform data Alexandru Ardelean
@ 2020-10-10 17:01 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2020-10-10 17:01 UTC (permalink / raw)
  To: Alexandru Ardelean; +Cc: linux-kernel, linux-iio

On Thu, 1 Oct 2020 17:10:48 +0300
Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:

> 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>
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to poke at it.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/ad7298.c             | 17 +++++++++--------
>  include/linux/platform_data/ad7298.h | 19 -------------------
>  2 files changed, 9 insertions(+), 27 deletions(-)
>  delete mode 100644 include/linux/platform_data/ad7298.h
> 
> 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;
> diff --git a/include/linux/platform_data/ad7298.h b/include/linux/platform_data/ad7298.h
> deleted file mode 100644
> index 3e0ffe2d5d3d..000000000000
> --- a/include/linux/platform_data/ad7298.h
> +++ /dev/null
> @@ -1,19 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0-only */
> -/*
> - * AD7298 SPI ADC driver
> - *
> - * Copyright 2011 Analog Devices Inc.
> - */
> -
> -#ifndef __LINUX_PLATFORM_DATA_AD7298_H__
> -#define __LINUX_PLATFORM_DATA_AD7298_H__
> -
> -/**
> - * struct ad7298_platform_data - Platform data for the ad7298 ADC driver
> - * @ext_ref: Whether to use an external reference voltage.
> - **/
> -struct ad7298_platform_data {
> -	bool ext_ref;
> -};
> -
> -#endif /* IIO_ADC_AD7298_H_ */


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-10 23:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-01 14:10 [PATCH] iio: adc: ad7298: rework external ref setup & remove platform data Alexandru Ardelean
2020-10-10 17:01 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).