]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hwmon: (ads7871) Fix incorrect error code in voltage_show
authorTabrez Ahmed <tabreztalks@gmail.com>
Sat, 7 Mar 2026 11:52:26 +0000 (17:22 +0530)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 31 Mar 2026 02:45:06 +0000 (19:45 -0700)
The voltage_show() function returns -1 when the A/D conversion
fails to complete within the polling loop. -1 maps to -EPERM
(operation not permitted), which does not describe the actual
failure.

Replace this -1 error code with -ETIMEDOUT to better indicate
the timeout condition to userspace.

Drop the else block after return.

Note: not runtime tested due to lack of hardware.

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

index b84426c940c5e53b625c8cdb0626d8ede8656ae7..753bf77ce19b4c8ae5c706d05681332c72f6cec1 100644 (file)
@@ -125,9 +125,9 @@ static ssize_t voltage_show(struct device *dev, struct device_attribute *da,
                /*result in volts*10000 = (val/8192)*2.5*10000*/
                val = ((val >> 2) * 25000) / 8192;
                return sysfs_emit(buf, "%d\n", val);
-       } else {
-               return -1;
        }
+
+       return -ETIMEDOUT;
 }
 
 static SENSOR_DEVICE_ATTR_RO(in0_input, voltage, 0);