Re: [PATCH v2 4/4] iio: adc: ti-ads7950: complete conversion to using managed resources
From: Jonathan Cameron
Date: Sun Feb 22 2026 - 09:09:52 EST
On Wed, 18 Feb 2026 18:29:28 -0800
Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx> 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>
Hi Dmitry
One additional comment from me.
> static int ti_ads7950_probe(struct spi_device *spi)
> {
> indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> @@ -598,36 +605,36 @@ static int ti_ads7950_probe(struct spi_device *spi)
> mutex_init(&st->slock);
>
> st->reg = devm_regulator_get(&spi->dev, "vref");
> - if (IS_ERR(st->reg)) {
> - ret = dev_err_probe(&spi->dev, PTR_ERR(st->reg),
> + error = PTR_ERR_OR_ZERO(st->reg);
To me this reads worse than original IS_ERR() / PTR_ERR() pair.
> + if (error)
> + return dev_err_probe(&spi->dev, error,
> "Failed to get regulator \"vref\"\n");
> - goto error_destroy_mutex;
> - }
>
> - ret = regulator_enable(st->reg);
> - if (ret) {
> - dev_err(&spi->dev, "Failed to enable regulator \"vref\"\n");
> - goto error_destroy_mutex;
> - }
> + error = regulator_enable(st->reg);
> + if (error)
> + return dev_err_probe(&spi->dev, error,
> + "Failed to enable regulator \"vref\"\n");