Re: [PATCH v4 3/4] iio: adc: ad799x: use devm_add_action_or_reset for regulators

From: Andy Shevchenko

Date: Sun Mar 08 2026 - 17:15:50 EST


On Sun, Mar 08, 2026 at 11:58:10PM +0530, Archit Anant wrote:
> Convert the manual regulator_disable() handling to use
> devm_add_action_or_reset(). This guarantees that the regulators are
> disabled in the correct reverse order of allocation during device
> teardown or probe failure.
>
> As part of this conversion, introduce a local device pointer to
> simplify function calls and remove redundant goto labels for regulator
> cleanup, as the devm framework now handles these automatically.

Needs to be split to two:
- moving to managed resources (and here you introduce temporary variable to reduce the churn)
- simplifying the old code with that variable

--
With Best Regards,
Andy Shevchenko