Re: [PATCH v2 4/4] iio: adc: ti-ads7950: complete conversion to using managed resources

From: David Lechner

Date: Sat Feb 21 2026 - 12:43:54 EST


On 2/18/26 8:29 PM, Dmitry Torokhov wrote:
> All resources that the driver needs have managed API now. Switch to
> using them to make code clearer and drop ti_ads7950_remove().
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
> ---
> drivers/iio/adc/ti-ads7950.c | 98 +++++++++++++++---------------------
> 1 file changed, 40 insertions(+), 58 deletions(-)
>
> diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c
> index d31397f37ec4..1c53e000bdcc 100644
> --- a/drivers/iio/adc/ti-ads7950.c
> +++ b/drivers/iio/adc/ti-ads7950.c
> @@ -528,19 +528,26 @@ static int ti_ads7950_init_hw(struct ti_ads7950_state *st)
> return 0;
> }
>
> +static void ti_ads7950_power_off(void *data)
> +{
> + struct ti_ads7950_state *st = data;
> +
> + regulator_disable(st->reg);
> +}
> +

For the regulator part, we can simplify this even more.

The part where we call regulator_get_voltage(st->reg); in
ti_ads7950_get_range() doesn't actually need to be done there.
It was something that I just naively copied from another driver.
(This was my first IIO driver after all!)

Instead, we can use devm_regulator_get_enable_read_voltage()
in the probe function and just store the voltage in
struct ti_ads7950_state.

I would do this in a separate patch first, then the rest of of
the devm stuff after that.


> static int ti_ads7950_probe(struct spi_device *spi)
> {
> struct ti_ads7950_state *st;
> struct iio_dev *indio_dev;
> const struct ti_ads7950_chip_info *info;
> - int ret;
> + int error;

As in the other patches, please do not rename ret. It is adding noise
in the diff. (And I like ret better anyway.)