From: "Rob Herring (Arm)" <robh@kernel.org>
To: Sebastian Reichel <sre@kernel.org>,
Hans de Goede <hansg@kernel.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>,
Purism Kernel Team <kernel@puri.sm>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] power: supply: Match DT value types
Date: Fri, 12 Jun 2026 16:53:07 -0500 [thread overview]
Message-ID: <20260612215308.1888834-1-robh@kernel.org> (raw)
The battery drivers read properties whose bindings use signed values
for temperature thresholds and unsigned values for voltage thresholds.
Some helpers used the opposite signedness, which makes property type
checking report real mismatches.
Use signed helpers where the binding and DTS allow negative values, and
use unsigned helpers for voltage properties documented as uint32 cells.
Assisted-by: Codex:gpt-5-5
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
drivers/power/supply/ltc2941-battery-gauge.c | 2 +-
drivers/power/supply/max17042_battery.c | 8 ++++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/power/supply/ltc2941-battery-gauge.c b/drivers/power/supply/ltc2941-battery-gauge.c
index a1ddc4b060ce..83cca11e92f6 100644
--- a/drivers/power/supply/ltc2941-battery-gauge.c
+++ b/drivers/power/supply/ltc2941-battery-gauge.c
@@ -463,7 +463,7 @@ static int ltc294x_i2c_probe(struct i2c_client *client)
/* r_sense can be negative, when sense+ is connected to the battery
* instead of the sense-. This results in reversed measurements. */
- ret = of_property_read_u32(np, "lltc,resistor-sense", &r_sense);
+ ret = of_property_read_s32(np, "lltc,resistor-sense", &r_sense);
if (ret < 0)
return dev_err_probe(&client->dev, ret,
"Could not find lltc,resistor-sense in devicetree\n");
diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 167fb3fb3732..6609cd74e5d3 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -967,10 +967,14 @@ max17042_get_of_pdata(struct max17042_chip *chip)
pdata->temp_min = INT_MIN;
if (of_property_read_s32(np, "maxim,over-heat-temp", &pdata->temp_max))
pdata->temp_max = INT_MAX;
- if (of_property_read_s32(np, "maxim,dead-volt", &pdata->vmin))
+ if (of_property_read_u32(np, "maxim,dead-volt", &prop))
pdata->vmin = INT_MIN;
- if (of_property_read_s32(np, "maxim,over-volt", &pdata->vmax))
+ else
+ pdata->vmin = prop;
+ if (of_property_read_u32(np, "maxim,over-volt", &prop))
pdata->vmax = INT_MAX;
+ else
+ pdata->vmax = prop;
return pdata;
}
--
2.53.0
reply other threads:[~2026-06-12 21:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260612215308.1888834-1-robh@kernel.org \
--to=robh@kernel.org \
--cc=hansg@kernel.org \
--cc=kernel@puri.sm \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=sebastian.krzyszkowiak@puri.sm \
--cc=sre@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