Re: [PATCH 05/13] iio: adc: ad7793: use dev_err_probe

From: Jonathan Cameron

Date: Sun Apr 12 2026 - 14:58:59 EST


On Mon, 30 Mar 2026 14:18:48 +0300
Antoniu Miclaus <antoniu.miclaus@xxxxxxxxxx> wrote:

> Use dev_err_probe() instead of dev_err() in the probe path to ensure
> proper handling of deferred probing and to simplify error handling.
>
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@xxxxxxxxxx>
> ---
> drivers/iio/adc/ad7793.c | 19 +++++++------------
> 1 file changed, 7 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c
> index 21c667e37b31..624530cce938 100644
> --- a/drivers/iio/adc/ad7793.c
> +++ b/drivers/iio/adc/ad7793.c
> @@ -278,8 +278,8 @@ static int ad7793_setup(struct iio_dev *indio_dev,
> id &= AD7793_ID_MASK;
>
> if (id != st->chip_info->id) {
> - ret = -ENODEV;
> - dev_err(&st->sd.spi->dev, "device ID query failed\n");
> + ret = dev_err_probe(&st->sd.spi->dev, -ENODEV,

There are quite a few instances of this dereference nest.
Unless other things come up in this set I don't mind it being dealt
with separately but to me it seems like a helper to make this
ret = dev_err_probe(adi_sigma_delta_get_dev(&st->sd), -ENODEV,
might be nice? Longer line but avoids diving into the implementation details
in a driver that shouldn't really be doing that.


> + "device ID query failed\n");
> goto out;
> }
>
> @@ -338,8 +338,7 @@ static int ad7793_setup(struct iio_dev *indio_dev,
>
> return 0;
> out:
> - dev_err(&st->sd.spi->dev, "setup failed\n");
> - return ret;
> + return dev_err_probe(&st->sd.spi->dev, ret, "setup failed\n");
> }
>
> static const u16 ad7793_sample_freq_avail[16] = {0, 470, 242, 123, 62, 50, 39,
> @@ -780,15 +779,11 @@ static int ad7793_probe(struct spi_device *spi)
> struct iio_dev *indio_dev;
> int ret, vref_mv = 0;
>
> - if (!pdata) {
> - dev_err(&spi->dev, "no platform data?\n");
> - return -ENODEV;
> - }
> + if (!pdata)
> + return dev_err_probe(dev, -ENODEV, "no platform data?\n");
>
> - if (!spi->irq) {
> - dev_err(&spi->dev, "no IRQ?\n");
> - return -ENODEV;
> - }
> + if (!spi->irq)
> + return dev_err_probe(dev, -ENODEV, "no IRQ?\n");
>
> indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
> if (indio_dev == NULL)