Linux IIO development
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: David Lechner <dlechner@baylibre.com>,
	Jonathan Cameron <jic23@kernel.org>
Cc: "Marcelo Schmitt" <marcelo.schmitt1@gmail.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 5/5] iio: adc: ad7944: use devm_regulator_get_enable_read_voltage
Date: Fri, 14 Jun 2024 17:16:54 +0200	[thread overview]
Message-ID: <6f607e60a781f74b3cde2405c8c6659d0e304c96.camel@gmail.com> (raw)
In-Reply-To: <20240612-iio-adc-ref-supply-refactor-v2-5-fa622e7354e9@baylibre.com>

On Wed, 2024-06-12 at 16:03 -0500, David Lechner wrote:
> This makes use of the new devm_regulator_get_enable_read_voltage()
> function to reduce boilerplate code.
> 
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---
> 
> v2 changes:
> - don't read voltage from refin regulator
> - avoid else in return value checks
> ---
>  drivers/iio/adc/ad7944.c | 54 +++++++++++-------------------------------------
>  1 file changed, 12 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7944.c b/drivers/iio/adc/ad7944.c
> index e2cb64cef476..f8bf03feba07 100644
> --- a/drivers/iio/adc/ad7944.c
> +++ b/drivers/iio/adc/ad7944.c
> @@ -464,23 +464,17 @@ static const char * const ad7944_power_supplies[] = {
>  	"avdd",	"dvdd",	"bvdd", "vio"
>  };
>  
> -static void ad7944_ref_disable(void *ref)
> -{
> -	regulator_disable(ref);
> -}
> -
>  static int ad7944_probe(struct spi_device *spi)
>  {
>  	const struct ad7944_chip_info *chip_info;
>  	struct device *dev = &spi->dev;
>  	struct iio_dev *indio_dev;
>  	struct ad7944_adc *adc;
> -	bool have_refin = false;
> -	struct regulator *ref;
> +	bool have_refin;
>  	struct iio_chan_spec *chain_chan;
>  	unsigned long *chain_scan_masks;
>  	u32 n_chain_dev;
> -	int ret;
> +	int ret, ref_mv;
>  
>  	indio_dev = devm_iio_device_alloc(dev, sizeof(*adc));
>  	if (!indio_dev)
> @@ -531,47 +525,23 @@ static int ad7944_probe(struct spi_device *spi)
>  	 * - external reference: REF is connected, REFIN is not connected
>  	 */
>  
> -	ref = devm_regulator_get_optional(dev, "ref");
> -	if (IS_ERR(ref)) {
> -		if (PTR_ERR(ref) != -ENODEV)
> -			return dev_err_probe(dev, PTR_ERR(ref),
> -					     "failed to get REF supply\n");
> +	ret = devm_regulator_get_enable_read_voltage(dev, "ref");
> +	if (ret < 0 && ret != -ENODEV)
> +		return dev_err_probe(dev, ret, "failed to get REF voltage\n");
>  
> -		ref = NULL;
> -	}
> +	ref_mv = ret == -ENODEV ? 0 : ret / 1000;
>  
>  	ret = devm_regulator_get_enable_optional(dev, "refin");
> -	if (ret == 0)
> -		have_refin = true;
> -	else if (ret != -ENODEV)
> -		return dev_err_probe(dev, ret,
> -				     "failed to get and enable REFIN supply\n");
> +	if (ret < 0 && ret == -ENODEV)
> +		return dev_err_probe(dev, ret, "failed to get REFIN voltage\n");
> +

ret != -ENODEV right?

- Nuno Sá



  reply	other threads:[~2024-06-14 15:16 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-12 21:03 [PATCH v2 0/5] iio: adc: use devm_regulator_get_enable_read_voltage round 1 David Lechner
2024-06-12 21:03 ` [PATCH v2 1/5] iio: adc: ad7192: use devm_regulator_get_enable_read_voltage David Lechner
2024-06-15 12:08   ` Jonathan Cameron
2024-06-17  9:35     ` Alisa-Dariana Roman
2024-06-17 13:22       ` David Lechner
2024-06-17 13:38         ` Alisa-Dariana Roman
2024-06-17 13:48           ` David Lechner
2024-06-17 14:10             ` Alisa-Dariana Roman
2024-06-17 15:28               ` David Lechner
2024-06-17 16:01                 ` Alisa-Dariana Roman
2024-06-17 20:00                   ` David Lechner
2024-06-18  9:45                     ` Alisa-Dariana Roman
2024-06-18 13:30                       ` David Lechner
2024-06-12 21:03 ` [PATCH v2 2/5] iio: adc: ad7266: " David Lechner
2024-06-15 12:12   ` Jonathan Cameron
2024-06-12 21:03 ` [PATCH v2 3/5] iio: adc: ad7292: " David Lechner
2024-06-14 15:11   ` Nuno Sá
2024-06-14 15:16     ` David Lechner
2024-06-15 12:14       ` Jonathan Cameron
2024-06-12 21:03 ` [PATCH v2 4/5] iio: adc: ad7793: " David Lechner
2024-06-15 12:15   ` Jonathan Cameron
2024-06-12 21:03 ` [PATCH v2 5/5] iio: adc: ad7944: " David Lechner
2024-06-14 15:16   ` Nuno Sá [this message]
2024-06-14 15:19     ` David Lechner
2024-06-15 12:18       ` Jonathan Cameron
2024-06-14 15:18 ` [PATCH v2 0/5] iio: adc: use devm_regulator_get_enable_read_voltage round 1 Nuno Sá

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6f607e60a781f74b3cde2405c8c6659d0e304c96.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=broonie@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.schmitt1@gmail.com \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox