* [PATCH] hwmon: (w83627hf) Clamp VRM9 voltage limits before subtracting
@ 2026-11-09 9:28 Zhu Jun
2026-11-09 9:36 ` sashiko-bot
0 siblings, 1 reply; 4+ messages in thread
From: Zhu Jun @ 2026-11-09 9:28 UTC (permalink / raw)
To: linux; +Cc: linux-hwmon, linux-kernel, zhujun
From: zhujun <zhujun2@cmss.chinamobile.com>
The VRM9 limit conversion subtracts the 700 mV offset from an unsigned
value before clamping. Writing zero to in0_min or in0_max therefore
selects register 255 instead of zero. Multiplication can also wrap for
large inputs.
Bound the input before applying the VRM9 conversion. The chosen bounds
cover the full register range and keep the arithmetic within range.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
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/w83627hf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index a26f4cdfb8e2..3ebb41db5033 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -853,7 +853,7 @@ static ssize_t in0_min_store(struct device *dev,
/* use VRM9 calculation */
data->in_min[0] =
- clamp_val(((val * 100) - 70000 + 244) / 488, 0, 255);
+ clamp_val((clamp_val(val, 700, 2000) * 100 - 70000 + 244) / 488, 0, 255);
else
/* use VRM8 (standard) calculation */
data->in_min[0] = IN_TO_REG(val);
@@ -892,7 +892,7 @@ static ssize_t in0_max_store(struct device *dev,
/* use VRM9 calculation */
data->in_max[0] =
- clamp_val(((val * 100) - 70000 + 244) / 488, 0, 255);
+ clamp_val((clamp_val(val, 700, 2000) * 100 - 70000 + 244) / 488, 0, 255);
else
/* use VRM8 (standard) calculation */
data->in_max[0] = IN_TO_REG(val);
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] hwmon: (w83627hf) Clamp VRM9 voltage limits before subtracting
2026-11-09 9:28 [PATCH] hwmon: (w83627hf) Clamp VRM9 voltage limits before subtracting Zhu Jun
@ 2026-11-09 9:36 ` sashiko-bot
0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-09 9:36 UTC (permalink / raw)
To: Zhu Jun; +Cc: linux-hwmon
> From: zhujun <zhujun2@cmss.chinamobile.com>
>
> The VRM9 limit conversion subtracts the 700 mV offset from an unsigned
> value before clamping. Writing zero to in0_min or in0_max therefore
> selects register 255 instead of zero. Multiplication can also wrap for
> large inputs.
>
> Bound the input before applying the VRM9 conversion. The chosen bounds
> cover the full register range and keep the arithmetic within range.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261109092816.5268-1-zhujun2@cmss.chinamobile.com?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] hwmon: (w83627hf) Clamp VRM9 voltage limits before subtracting
@ 2026-11-11 6:48 Zhu Jun
2026-11-11 7:00 ` sashiko-bot
0 siblings, 1 reply; 4+ messages in thread
From: Zhu Jun @ 2026-11-11 6:48 UTC (permalink / raw)
To: linux; +Cc: linux-hwmon, linux-kernel, Zhu Jun
The VRM9 limit conversion subtracts the 700 mV offset from an unsigned
value before clamping. Writing zero to in0_min or in0_max therefore
selects register 255 instead of zero. Multiplication can also wrap for
large inputs.
Bound the input before applying the VRM9 conversion. The chosen bounds
cover the full register range and keep the arithmetic within range.
Fixes: 1da177e4c3f41 ("Linux-2.6.12-rc2")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
drivers/hwmon/w83627hf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index a26f4cdfb8e2..3ebb41db5033 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -853,7 +853,7 @@ static ssize_t in0_min_store(struct device *dev,
/* use VRM9 calculation */
data->in_min[0] =
- clamp_val(((val * 100) - 70000 + 244) / 488, 0, 255);
+ clamp_val((clamp_val(val, 700, 2000) * 100 - 70000 + 244) / 488, 0, 255);
else
/* use VRM8 (standard) calculation */
data->in_min[0] = IN_TO_REG(val);
@@ -892,7 +892,7 @@ static ssize_t in0_max_store(struct device *dev,
/* use VRM9 calculation */
data->in_max[0] =
- clamp_val(((val * 100) - 70000 + 244) / 488, 0, 255);
+ clamp_val((clamp_val(val, 700, 2000) * 100 - 70000 + 244) / 488, 0, 255);
else
/* use VRM8 (standard) calculation */
data->in_max[0] = IN_TO_REG(val);
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] hwmon: (w83627hf) Clamp VRM9 voltage limits before subtracting
2026-11-11 6:48 Zhu Jun
@ 2026-11-11 7:00 ` sashiko-bot
0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-11 7:00 UTC (permalink / raw)
To: Zhu Jun; +Cc: linux-hwmon
> The VRM9 limit conversion subtracts the 700 mV offset from an unsigned
> value before clamping. Writing zero to in0_min or in0_max therefore
> selects register 255 instead of zero. Multiplication can also wrap for
> large inputs.
>
> Bound the input before applying the VRM9 conversion. The chosen bounds
> cover the full register range and keep the arithmetic within range.
>
> Fixes: 1da177e4c3f41 ("Linux-2.6.12-rc2")
> 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/20261111064900.17338-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-09 9:28 [PATCH] hwmon: (w83627hf) Clamp VRM9 voltage limits before subtracting Zhu Jun
2026-11-09 9:36 ` sashiko-bot
-- strict thread matches above, loose matches on Subject: below --
2026-11-11 6:48 Zhu Jun
2026-11-11 7:00 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox