From: Guenter Roeck <linux@roeck-us.net>
To: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Cc: Nuno Sa <nuno.sa@analog.com>, Guenter Roeck <linux@roeck-us.net>,
Sashiko <sashiko-bot@kernel.org>
Subject: [PATCH 3/3] hwmon: (ltc4282) Fix parsing adi,current-limit-sense-microvolt
Date: Tue, 4 Aug 2026 17:57:21 -0700 [thread overview]
Message-ID: <20260805005721.1566034-4-linux@roeck-us.net> (raw)
In-Reply-To: <20260805005721.1566034-1-linux@roeck-us.net>
ltc4282_parse_dt() evaluates the wrong variable when parsing the current
limit.
When the adi,current-limit-sense-microvolt property is parsed into
st->vsense_max, the subsequent switch statement evaluates the unrelated
val variable instead of st->vsense_max:
drivers/hwmon/ltc4282.c:ltc4282_parse_dt() {
...
ret = device_property_read_u32(dev, "adi,current-limit-sense-microvolt",
&st->vsense_max);
if (!ret) {
int reg_val;
switch (val) {
case 12500:
reg_val = 0;
break;
...
}
Because val holds a small integer representing vin_mode (from 0 to 3), it
never matches any of the valid current limit cases.
This causes it to always fall through to the default error case, return
-EINVAL, and aborts probe initialization for any device tree using this
property.
Validate st->vsense_max instead to fix the problem.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Fixes: cbc29538dbf7d ("hwmon: Add driver for LTC4282")
Cc: Nuno Sa <nuno.sa@analog.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/hwmon/ltc4282.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwmon/ltc4282.c b/drivers/hwmon/ltc4282.c
index bb1bcb369016..b1675dc5b3c7 100644
--- a/drivers/hwmon/ltc4282.c
+++ b/drivers/hwmon/ltc4282.c
@@ -1394,7 +1394,7 @@ static int ltc4282_setup(struct ltc4282_state *st, struct device *dev)
if (!ret) {
int reg_val;
- switch (val) {
+ switch (st->vsense_max) {
case 12500:
reg_val = 0;
break;
--
2.45.2
next prev parent reply other threads:[~2026-08-05 0:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 0:57 [PATCH 0/3] hwmon: (ltc4282) Fix issues reported by Sashiko Guenter Roeck
2026-08-05 0:57 ` [PATCH 1/3] hwmon: (ltc4282) Avoid overflow in maximum power calculation Guenter Roeck
2026-08-05 1:07 ` sashiko-bot
2026-08-05 0:57 ` [PATCH 2/3] hwmon: (ltc4282) Clamp negative current limits Guenter Roeck
2026-08-05 1:04 ` sashiko-bot
2026-08-05 9:22 ` Nuno Sá
2026-08-05 15:41 ` Guenter Roeck
2026-08-05 16:14 ` Nuno Sá
2026-08-05 17:19 ` Guenter Roeck
2026-08-05 0:57 ` Guenter Roeck [this message]
2026-08-05 1:08 ` [PATCH 3/3] hwmon: (ltc4282) Fix parsing adi,current-limit-sense-microvolt sashiko-bot
2026-08-05 9:26 ` [PATCH 0/3] hwmon: (ltc4282) Fix issues reported by Sashiko Nuno Sá
2026-08-05 14:28 ` Guenter Roeck
2026-08-05 16:15 ` Nuno Sá
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260805005721.1566034-4-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=linux-hwmon@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=sashiko-bot@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox