]> git.ipfire.org Git - thirdparty/linux.git/commit
hwmon: (ads7871) Propagate SPI errors in voltage_show
authorTabrez Ahmed <tabreztalks@gmail.com>
Sun, 8 Mar 2026 12:47:14 +0000 (18:17 +0530)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 31 Mar 2026 02:45:06 +0000 (19:45 -0700)
commit487a9ab28fdd4df773b68c953e69a6f6ecc2fe68
treeb3705c5b5a8a50d1a2f5d9fc007cb4c843956af7
parent0a42986b65776759490ac960910651c1e4634b17
hwmon: (ads7871) Propagate SPI errors in voltage_show

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@roeck-us.net>
Signed-off-by: Tabrez Ahmed <tabreztalks@gmail.com>
Link: https://lore.kernel.org/r/20260308124714.84715-1-tabreztalks@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/ads7871.c