Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: "César Bispo" <dm.cesaraugusto@gmail.com>
Cc: jic23@kernel.org, linux-iio@vger.kernel.org,
	"César Bispo" <cesar.bispo@ime.usp.br>,
	"Gabriel Ferreira" <gabrielfsouza.araujo@usp.br>
Subject: Re: [PATCH v1] iio: adc: Use devm_iio_device_register() and dev_err_probe()
Date: Wed, 25 Jun 2025 10:11:19 +0100	[thread overview]
Message-ID: <20250625101119.00003c34@huawei.com> (raw)
In-Reply-To: <20250625023402.86861-1-cesar.bispo@ime.usp.br>

On Tue, 24 Jun 2025 23:33:51 -0300
"César Bispo" <dm.cesaraugusto@gmail.com> wrote:

> Replace iio_device_register() with devm_iio_device_register() to let the
> core handle cleanup automatically. This simplifies the driver and avoids
> manual error paths.
> 
> Also use dev_err_probe() for improved error handling and cleaner logs
> when deferrals happen.
> 
Hi. Always include the driver name in the patch title so that people
can quickly see if they care about it not!

iio: adc: qcom-pm8xxx-xoadc: USe devm_iio_device_register() and dev_err_probe()

> 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>
> ---
>  drivers/iio/adc/qcom-pm8xxx-xoadc.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/adc/qcom-pm8xxx-xoadc.c b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
> index 31f88cf7f7f1..447a924eca6d 100644
> --- a/drivers/iio/adc/qcom-pm8xxx-xoadc.c
> +++ b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
> @@ -934,20 +934,18 @@ static int pm8xxx_xoadc_probe(struct platform_device *pdev)
>  	indio_dev->channels = adc->iio_chans;
>  	indio_dev->num_channels = adc->nchans;
>  
> -	ret = iio_device_register(indio_dev);
> +	ret = devm_iio_device_register(dev, indio_dev);
Look at how devm works before considering any such changes.
This change creates a race where you have turned the
power off before removing the userspace interfaces which is a very bad idea.

>  	if (ret)
> -		goto out_disable_vref;
> +		return dev_err_probe(dev, ret, "Unable to register %s\n", indio_dev->name);
>  
>  	ret = pm8xxx_calibrate_device(adc);
>  	if (ret)
> -		goto out_unreg_device;
> +		return ret;
>  
>  	dev_info(dev, "%s XOADC driver enabled\n", variant->name);
>  
>  	return 0;
>  
> -out_unreg_device:
> -	iio_device_unregister(indio_dev);
>  out_disable_vref:
>  	regulator_disable(adc->vref);
>  


  reply	other threads:[~2025-06-25  9:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-25  2:33 [PATCH v1] iio: adc: Use devm_iio_device_register() and dev_err_probe() César Bispo
2025-06-25  9:11 ` Jonathan Cameron [this message]
2025-06-25 13:27   ` [PATCH v1] iio: adc: qcom-pm8xxx-xoadc: " César Bispo
2025-06-26 18:36     ` 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=20250625101119.00003c34@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=cesar.bispo@ime.usp.br \
    --cc=dm.cesaraugusto@gmail.com \
    --cc=gabrielfsouza.araujo@usp.br \
    --cc=jic23@kernel.org \
    --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