* [PATCH] hwmon: (ads7871) Fix incorrect error code in voltage_show
@ 2026-03-07 10:16 Tabrez Ahmed
2026-03-07 10:47 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Tabrez Ahmed @ 2026-03-07 10:16 UTC (permalink / raw)
To: Guenter Roeck
Cc: linux-hwmon, linux-kernel, Shuah Khan, Brigham Campbell,
Tabrez Ahmed
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.
Note: not runtime tested due to lack of hardware.
Signed-off-by: Tabrez Ahmed <tabreztalks@gmail.com>
---
Note: This patch applies on top of my previously submitted patch:
"hwmon: (ads7871) Replace sprintf() with sysfs_emit()"
drivers/hwmon/ads7871.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
index b84426c940c5e..4df54c86f786c 100644
--- a/drivers/hwmon/ads7871.c
+++ b/drivers/hwmon/ads7871.c
@@ -126,7 +126,7 @@ static ssize_t voltage_show(struct device *dev, struct device_attribute *da,
val = ((val >> 2) * 25000) / 8192;
return sysfs_emit(buf, "%d\n", val);
} else {
- return -1;
+ return -ETIMEDOUT;
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] hwmon: (ads7871) Fix incorrect error code in voltage_show
2026-03-07 10:16 [PATCH] hwmon: (ads7871) Fix incorrect error code in voltage_show Tabrez Ahmed
@ 2026-03-07 10:47 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2026-03-07 10:47 UTC (permalink / raw)
To: Tabrez Ahmed; +Cc: linux-hwmon, linux-kernel, Shuah Khan, Brigham Campbell
Hi,
On 3/7/26 02:16, Tabrez Ahmed wrote:
> 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.
>
> Note: not runtime tested due to lack of hardware.
>
> Signed-off-by: Tabrez Ahmed <tabreztalks@gmail.com>
> ---
> Note: This patch applies on top of my previously submitted patch:
> "hwmon: (ads7871) Replace sprintf() with sysfs_emit()"
>
> drivers/hwmon/ads7871.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
> index b84426c940c5e..4df54c86f786c 100644
> --- a/drivers/hwmon/ads7871.c
> +++ b/drivers/hwmon/ads7871.c
> @@ -126,7 +126,7 @@ static ssize_t voltage_show(struct device *dev, struct device_attribute *da,
> val = ((val >> 2) * 25000) / 8192;
> return sysfs_emit(buf, "%d\n", val);
> } else {
> - return -1;
> + return -ETIMEDOUT;
> }
> }
>
Good find, but please also drop the else (else after return is unnecessary).
Thanks,
Guenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-07 10:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-07 10:16 [PATCH] hwmon: (ads7871) Fix incorrect error code in voltage_show Tabrez Ahmed
2026-03-07 10:47 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox