Re: [PATCH] hwmon: (ads7871) Propagate SPI errors in voltage_show
From: Guenter Roeck
Date: Sun Mar 08 2026 - 11:03:25 EST
On Sun, Mar 08, 2026 at 06:17:14PM +0530, Tabrez Ahmed wrote:
> The voltage_show() function previously ignored negative error codes
> returned by the underlying SPI read/write functions. Because negative
> numbers have their most significant bits set in two's complement, a
> failed SPI read returning -EIO (-5) would incorrectly evaluate to true
> when masked with MUX_CNV_BM (0x80).
>
> This would cause the driver to enter the polling loop even when the SPI bus
> failed, eventually returning a misleading -ETIMEDOUT error to userspace
> instead of the actual hardware error. Furthermore, the return values of
> the initial SPI write and the final 16-bit SPI read were completely
> ignored.
>
> Add proper error checking after every SPI operation to ensure hardware
> failures are immediately propagated back to userspace.
>
> Suggested-by: Guenter Roeck <linux@xxxxxxxxxxxx>
> Signed-off-by: Tabrez Ahmed <tabreztalks@xxxxxxxxx>
Applied.
Thanks,
Guenter