Linux IIO development
 help / color / mirror / Atom feed
* [PATCH v1] iio: adc: Use devm_iio_device_register() and dev_err_probe()
@ 2025-06-25  2:33 César Bispo
  2025-06-25  9:11 ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: César Bispo @ 2025-06-25  2:33 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, César Bispo, Gabriel Ferreira

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.

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);
 	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);
 
-- 
2.43.0


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

end of thread, other threads:[~2025-06-26 18:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-06-25 13:27   ` [PATCH v1] iio: adc: qcom-pm8xxx-xoadc: " César Bispo
2025-06-26 18:36     ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox