Re: [PATCH] staging: iio: adc: ad7816: add timeout to busy-wait loop

From: Dan Carpenter

Date: Thu Feb 26 2026 - 04:21:08 EST


On Thu, Feb 26, 2026 at 08:25:35AM +0000, Ruslan Valiyev wrote:
> On Thu, Feb 26, 2026 at 05:26:15AM +0000, Andy Shevchenko wrote:
> > Have you able to test this?
>
> No, I don't have AD7816 hardware, compile-tested only.
>
> > Have you investigated the code? It was an atomic, now it's sleeping.
> > This is a huge behavioural change. See my first Q.
>
> You're right, the sleeping change was unnecessary. ad7816_spi_read()
> is only called from ad7816_show_value(), a sysfs show callback, so
> it runs in process context. But for a wait of at most 27 us per the
> datasheet, there's no benefit to sleeping. The atomic variant adds
> the timeout protection while preserving the original busy-wait
> semantics.
>

So this is only from reading the datasheet and the code? I had assumed
this was something you experienced yourself in real life.

regards,
dan carpenter