Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Cesar Bispo <dm.cesaraugusto@gmail.com>
Cc: linux-iio@vger.kernel.org, Cesar Bispo <cesar.bispo@ime.usp.br>,
	GabrIel Ferreira <gabrielfsouza.araujo@usp.br>
Subject: Re: [PATCH 1/2] iio: adc: ad7476: modernize single regulator call
Date: Tue, 29 Apr 2025 18:37:57 +0100	[thread overview]
Message-ID: <20250429183757.14fdeee7@jic23-huawei> (raw)
In-Reply-To: <20250429160526.5934-2-cesar.bispo@ime.usp.br>

On Tue, 29 Apr 2025 13:05:18 -0300
Cesar Bispo <dm.cesaraugusto@gmail.com> wrote:

> Replace a single instance of legacy regulator handling in each driver
> with devm_regulator_get_enable() and devm_regulator_get_enable_optional().
> This change improves code clarity and aligns with modern kernel APIs.
> 
> Signed-off-by: Cesar Bispo <cesar.bispo@ime.usp.br>
> Co-developed-by: GabrIel Ferreira <gabrielfsouza.araujo@usp.br>
> Signed-off-by: GabrIel Ferreira <gabrielfsouza.araujo@usp.br>
Take a closer look at the signatures of these functions.

I'm a bit surprised if this builds.
> ---
>  drivers/iio/adc/ad7476.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
> index 37b0515cf4fc..33155f76230e 100644
> --- a/drivers/iio/adc/ad7476.c
> +++ b/drivers/iio/adc/ad7476.c
> @@ -314,7 +314,7 @@ static int ad7476_probe(struct spi_device *spi)
>  	st->chip_info =
>  		&ad7476_chip_info_tbl[spi_get_device_id(spi)->driver_data];
>  
> -	reg = devm_regulator_get(&spi->dev, "vcc");
> +	reg = devm_regulator_get_enable(&spi->dev, "vcc");
>  	if (IS_ERR(reg))
>  		return PTR_ERR(reg);
>  
> @@ -334,11 +334,11 @@ static int ad7476_probe(struct spi_device *spi)
>  
>  		/* If a device has an internal reference vref is optional */
>  		if (st->chip_info->int_vref_uv) {
> -			reg = devm_regulator_get_optional(&spi->dev, "vref");
> +			reg = devm_regulator_get_enable_optional(&spi->dev, "vref");
>  			if (IS_ERR(reg) && (PTR_ERR(reg) != -ENODEV))
>  				return PTR_ERR(reg);
>  		} else {
> -			reg = devm_regulator_get(&spi->dev, "vref");
> +			reg = devm_regulator_get_enable(&spi->dev, "vref");
>  			if (IS_ERR(reg))
>  				return PTR_ERR(reg);
>  		}


  reply	other threads:[~2025-04-29 17:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-29 16:05 [PATCH 0/2] iio: adc: Modernize legacy regulator calls in drivers Cesar Bispo
2025-04-29 16:05 ` [PATCH 1/2] iio: adc: ad7476: modernize single regulator call Cesar Bispo
2025-04-29 17:37   ` Jonathan Cameron [this message]
2025-04-29 16:05 ` [PATCH 2/2] iio: adc: qcom-pm8xxx-xoadc: " Cesar Bispo
2025-04-29 17:38   ` Jonathan Cameron

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=20250429183757.14fdeee7@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=cesar.bispo@ime.usp.br \
    --cc=dm.cesaraugusto@gmail.com \
    --cc=gabrielfsouza.araujo@usp.br \
    --cc=linux-iio@vger.kernel.org \
    /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