Re: [PATCH v5 8/8] iio: adc: at91_adc: convert to device-managed resources
From: Jonathan Cameron
Date: Sat Nov 28 2026 - 18:34:49 EST
On Mon, 23 Nov 2026 09:01:01 +0200
Abdelnasser Hussein <abdelnasserhussein11@xxxxxxxxx> wrote:
> Convert the driver to device-managed APIs so that all resources are
> freed automatically on probe failure and on driver detach:
> - allocate and register the IIO triggers directly in at91_adc_probe()
> with devm_iio_trigger_alloc() and devm_iio_trigger_register(),
> dropping at91_adc_allocate_trigger(), at91_adc_trigger_init() and
> at91_adc_trigger_remove() along with their manual rollback paths.
> The st->trig array is no longer needed and is removed as well, since
> the triggers are now owned by devres
> - set up the triggered buffer with devm_iio_triggered_buffer_setup()
> directly in at91_adc_probe(), dropping at91_adc_buffer_init() and
> at91_adc_buffer_remove()
> - allocate the touchscreen input device with
> devm_input_allocate_device(), dropping at91_ts_unregister() and the
> manual input_free_device() error path in at91_ts_register()
> - register the IIO device with devm_iio_device_register()
This is too much information given we can just look at the patch.
Something that calls out the main topic then anything unusual.
Convert the driver to device-managed APIs so that all resources are
freed automatically on probe failure or driver detach.
Includes dropping redundant error messages and helpers.
The triggers are now only directly referred to in probe() so drop the
pointers from struct at91_adc_state.
>
> Redundant allocation error messages ("Failed to allocate TS device!" and
> "Couldn't setup the triggers.") are dropped, and at91_ts_register() now
> uses dev_err_probe() to report its remaining error. Errors from
> devm_iio_trigger_register() are reported with dev_err_probe() as well.
>
> at91_adc_probe() no longer needs any error unwinding labels and
> at91_adc_remove() is removed together with the platform driver's
> .remove callback.
>
> Suggested-by: Jonathan Cameron <jic23@xxxxxxxxxx>
> Signed-off-by: Abdelnasser Hussein <abdelnasserhussein11@xxxxxxxxx>
Code looks fine to me but this is the sort of thing where Sashiko
really comes into its own wrt to catching corner cases humans miss.
Jonathan