Re: [PATCH] staging: iio: adc: ad7816: add timeout to busy-wait loop
From: Ruslan Valiyev
Date: Thu Feb 26 2026 - 03:25:45 EST
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.
I've respun as v2 using read_poll_timeout_atomic(). Also fixed the
commit message: v1 incorrectly said the original loop treated
negative gpiod_get_value() errors as "not-busy", it's the opposite,
negative is non-zero so the loop treats it as busy and spins forever.
Ruslan