Re: [PATCH v2] staging: iio: addac: adt7316: check SPI write errors in probe

From: Denny Lin

Date: Sat May 09 2026 - 22:00:39 EST


Hi Nuno, Maxwell,

Thanks for the feedback.

I agree that just warning is not very useful, and we should bail out on
errors if we check them. However, I currently cannot test the failure
case and I'm not sure how the device behaves if the switching sequence
is interrupted.

I've reached out to Analog Devices to clarify this. For now, I think it's
safer not to change the behavior until we have confirmation.

I'll follow up once I have more information.

Thanks,
Hungyu

On Sat, May 9, 2026 at 1:26 PM Maxwell Doose <m32285159@xxxxxxxxx> wrote:
>
> On Sat, May 9, 2026 at 4:03 AM Hungyu Lin <dennylin0707@xxxxxxxxx> 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.
> >
> > Signed-off-by: Hungyu Lin <dennylin0707@xxxxxxxxx>
> > ---
> > Changes in v2:
> > - Return error instead of just warning
> > - Clarify that repeated SPI writes are converted to a loop
> > ---
> > drivers/staging/iio/addac/adt7316-spi.c | 9 ++++++---
> > 1 file changed, 6 insertions(+), 3 deletions(-)
> >
> [snip]
>
> Hmmm...has this been tested? Normally patches like these don't get
> merged unless tested since we need to know how the hardware would
> respond when we hit an error case and quit sending data, and also some
> of the timing changes introduced by writing, checking if its an error,
> then jumping back. I've personally tried this patch before and it got
> rejected so I'll link it below since the questions that you might get
> asked will likely be similar.
>
> Link: https://lore.kernel.org/linux-iio/20260426205039.125818-1-m32285159@xxxxxxxxx/
>
> best regards,
> max