Re: [PATCH] staging: iio: adt7316: Add error handling to adt7316_spi_probe()

Andy Shevchenko
2026-04-27T08:32:54Z

On Sun, Apr 26, 2026 at 03:50:38PM -0500, Maxwell Doose wrote:
> Currently, the return values of the adt7316_spi_write() calls in
> adt7316_spi_probe() are unchecked. Add error handling to return early
> and pass on the error code if we receive an error from
> adt7316_spi_write().
>
> While at it, move all three adt7316_spi_write() calls inside a for loop
> to condense the logic.

...

> - 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++) {

for (unsigned int i = 0; i < 3; i++) {

The magic 3 has to be explained in the comment above.

> + ret = adt7316_spi_write(spi_dev, 0, 0);
> + /* Check for errors, if we get an error, return early */
> + if (ret < 0)
> + return ret;
> + }

Are you sure that's fine to make those fatal? Have you read datasheet on this?
maybe it will return errors which we have to ignore?

--
With Best Regards,
Andy Shevchenko