Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: adc: ad799x: use devm_iio_device_register and devm buffer setup
@ 2026-02-28 15:45 Archit Anant
  2026-02-28 16:36 ` David Lechner
  2026-03-01 11:37 ` Jonathan Cameron
  0 siblings, 2 replies; 7+ messages in thread
From: Archit Anant @ 2026-02-28 15:45 UTC (permalink / raw)
  To: jic23, lars, Michael.Hennerich
  Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel, Archit Anant

Convert the driver to use the device-managed versions of
iio_device_register() and iio_triggered_buffer_setup().

This simplifies the error handling in ad799x_probe() by removing the
'error_cleanup_ring' goto label. It also removes the need to manually
call iio_device_unregister() and iio_triggered_buffer_cleanup() in
ad799x_remove().

Signed-off-by: Archit Anant <architanant5@gmail.com>
---
 drivers/iio/adc/ad799x.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
index 108bb22162ef..42712372acdb 100644
--- a/drivers/iio/adc/ad799x.c
+++ b/drivers/iio/adc/ad799x.c
@@ -847,7 +847,7 @@ static int ad799x_probe(struct i2c_client *client)
 	if (ret)
 		goto error_disable_vref;
 
-	ret = iio_triggered_buffer_setup(indio_dev, NULL,
+	ret = devm_iio_triggered_buffer_setup(&client->dev, indio_dev, NULL,
 		&ad799x_trigger_handler, NULL);
 	if (ret)
 		goto error_disable_vref;
@@ -862,19 +862,17 @@ static int ad799x_probe(struct i2c_client *client)
 						client->name,
 						indio_dev);
 		if (ret)
-			goto error_cleanup_ring;
+			goto error_disable_vref;
 	}
 
 	mutex_init(&st->lock);
 
-	ret = iio_device_register(indio_dev);
+	ret = devm_iio_device_register(&client->dev, indio_dev);
 	if (ret)
-		goto error_cleanup_ring;
+		goto error_disable_vref;
 
 	return 0;
 
-error_cleanup_ring:
-	iio_triggered_buffer_cleanup(indio_dev);
 error_disable_vref:
 	if (st->vref)
 		regulator_disable(st->vref);
@@ -889,9 +887,6 @@ static void ad799x_remove(struct i2c_client *client)
 	struct iio_dev *indio_dev = i2c_get_clientdata(client);
 	struct ad799x_state *st = iio_priv(indio_dev);
 
-	iio_device_unregister(indio_dev);
-
-	iio_triggered_buffer_cleanup(indio_dev);
 	if (st->vref)
 		regulator_disable(st->vref);
 	regulator_disable(st->reg);
-- 
2.39.5


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

end of thread, other threads:[~2026-03-01 16:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-28 15:45 [PATCH] iio: adc: ad799x: use devm_iio_device_register and devm buffer setup Archit Anant
2026-02-28 16:36 ` David Lechner
2026-02-28 17:19   ` Archit Anant
2026-02-28 17:35     ` David Lechner
2026-03-01 11:34       ` Jonathan Cameron
2026-03-01 16:46         ` David Lechner
2026-03-01 11:37 ` Jonathan Cameron

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