Re: [PATCH v2] staging: iio: addac: adt7316: check SPI write errors in probe
From: Andy Shevchenko
Date: Sun May 10 2026 - 02:23:15 EST
On Sat, May 09, 2026 at 09:03:20AM +0000, Hungyu Lin wrote:
> The probe function issues three SPI writes to switch the device
> from the default I2C protocol to SPI protocol, but ignores their
> return values.
>
> Switch the repeated SPI writes to a loop and return an error
> if any of them fail, as failing to switch the protocol should
> abort the probe.
...
> /* switch from default I2C protocol to SPI protocol */
> - adt7316_spi_write(spi_dev, 0, 0);
> - adt7316_spi_write(spi_dev, 0, 0);
> - adt7316_spi_write(spi_dev, 0, 0);
> + for (i = 0; i < 3; i++) {
> + ret = adt7316_spi_write(spi_dev, 0, 0);
> + if (ret)
> + return ret;
> + }
There was an attempt in the past to do the same and it was NAKed, so is this now.
NAK.
Instead, add a better comment, if you wish, with the citing from the datasheet
to explain the magic here and why we don't check for the error codes.
--
With Best Regards,
Andy Shevchenko