* [PATCH] hwmon: (w83793) Prevent underflow when removing voltage offsets
@ 2026-11-09 9:31 Zhu Jun
2026-11-09 9:39 ` sashiko-bot
0 siblings, 1 reply; 4+ messages in thread
From: Zhu Jun @ 2026-11-09 9:31 UTC (permalink / raw)
To: r.marek; +Cc: linux, linux-hwmon, linux-kernel, zhujun
From: zhujun <zhujun2@cmss.chinamobile.com>
The 5VDD and 5VSB limit conversion subtracts the voltage offset from an
unsigned value. A requested limit below the offset wraps and is clamped
to 255. For example, writing zero to in7_min selects the highest limit
instead of the lowest.
Limit the subtraction to the converted input so that values below the
offset select register zero.
Fixes: ddca933bd554 ("hwmon/w83793: Remove the description of AMDSI and update the voltage formula")
---
Validation: x86-64 and i386 driver objects built with W=1.
Source-extracted boundary tests passed on 32-bit and 64-bit;
the corresponding test fails on the base revision. I/O is mocked.
No physical sensor hardware or booted-kernel test was available.
OpenAI Codex assisted analysis, code, tests and changelog drafting.
The human submitter must review and add their Signed-off-by.
drivers/hwmon/w83793.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index e1f2708b5db6..b1d390904fe4 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -991,7 +991,7 @@ store_in(struct device *dev, struct device_attribute *attr,
if (index > 2) {
/* fix the limit values of 5VDD and 5VSB to ALARM mechanism */
if (nr == 1 || nr == 2)
- val -= scale_in_add[index] / scale_in[index];
+ val -= min_t(unsigned long, val, scale_in_add[index] / scale_in[index]);
val = clamp_val(val, 0, 255);
} else {
val = clamp_val(val, 0, 0x3FF);
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] hwmon: (w83793) Prevent underflow when removing voltage offsets
2026-11-09 9:31 Zhu Jun
@ 2026-11-09 9:39 ` sashiko-bot
0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-09 9:39 UTC (permalink / raw)
To: Zhu Jun; +Cc: linux-hwmon
> From: zhujun <zhujun2@cmss.chinamobile.com>
>
> The 5VDD and 5VSB limit conversion subtracts the voltage offset from an
> unsigned value. A requested limit below the offset wraps and is clamped
> to 255. For example, writing zero to in7_min selects the highest limit
> instead of the lowest.
>
> Limit the subtraction to the converted input so that values below the
> offset select register zero.
>
> Fixes: ddca933bd554 ("hwmon/w83793: Remove the description of AMDSI and update the voltage formula")
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261109093132.5347-1-zhujun2@cmss.chinamobile.com?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] hwmon: (w83793) Prevent underflow when removing voltage offsets
@ 2026-11-11 6:49 Zhu Jun
2026-11-11 6:59 ` sashiko-bot
0 siblings, 1 reply; 4+ messages in thread
From: Zhu Jun @ 2026-11-11 6:49 UTC (permalink / raw)
To: r.marek; +Cc: linux, linux-hwmon, linux-kernel, Zhu Jun
The 5VDD and 5VSB limit conversion subtracts the voltage offset from an
unsigned value. A requested limit below the offset wraps and is clamped
to 255. For example, writing zero to in7_min selects the highest limit
instead of the lowest.
Limit the subtraction to the converted input so that values below the
offset select register zero.
Fixes: ddca933bd554 ("hwmon/w83793: Remove the description of AMDSI and update the voltage formula")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
drivers/hwmon/w83793.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index e1f2708b5db6..b1d390904fe4 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -991,7 +991,7 @@ store_in(struct device *dev, struct device_attribute *attr,
if (index > 2) {
/* fix the limit values of 5VDD and 5VSB to ALARM mechanism */
if (nr == 1 || nr == 2)
- val -= scale_in_add[index] / scale_in[index];
+ val -= min_t(unsigned long, val, scale_in_add[index] / scale_in[index]);
val = clamp_val(val, 0, 255);
} else {
val = clamp_val(val, 0, 0x3FF);
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] hwmon: (w83793) Prevent underflow when removing voltage offsets
2026-11-11 6:49 [PATCH] hwmon: (w83793) Prevent underflow when removing voltage offsets Zhu Jun
@ 2026-11-11 6:59 ` sashiko-bot
0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-11 6:59 UTC (permalink / raw)
To: Zhu Jun; +Cc: linux-hwmon
> The 5VDD and 5VSB limit conversion subtracts the voltage offset from an
> unsigned value. A requested limit below the offset wraps and is clamped
> to 255. For example, writing zero to in7_min selects the highest limit
> instead of the lowest.
>
> Limit the subtraction to the converted input so that values below the
> offset select register zero.
>
> Fixes: ddca933bd554 ("hwmon/w83793: Remove the description of AMDSI and update the voltage formula")
> Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261111064918.17360-1-zhujun2@cmss.chinamobile.com?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-11 7:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-11 6:49 [PATCH] hwmon: (w83793) Prevent underflow when removing voltage offsets Zhu Jun
2026-11-11 6:59 ` sashiko-bot
-- strict thread matches above, loose matches on Subject: below --
2026-11-09 9:31 Zhu Jun
2026-11-09 9:39 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox