* [PATCH] power: supply: Match DT value types
@ 2026-06-12 21:53 Rob Herring (Arm)
2026-06-13 7:47 ` Krzysztof Kozlowski
0 siblings, 1 reply; 2+ messages in thread
From: Rob Herring (Arm) @ 2026-06-12 21:53 UTC (permalink / raw)
To: Sebastian Reichel, Hans de Goede, Krzysztof Kozlowski,
Marek Szyprowski, Sebastian Krzyszkowiak, Purism Kernel Team
Cc: linux-pm, linux-kernel
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] power: supply: Match DT value types
2026-06-12 21:53 [PATCH] power: supply: Match DT value types Rob Herring (Arm)
@ 2026-06-13 7:47 ` Krzysztof Kozlowski
0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2026-06-13 7:47 UTC (permalink / raw)
To: Rob Herring (Arm), Sebastian Reichel, Hans de Goede,
Marek Szyprowski, Sebastian Krzyszkowiak, Purism Kernel Team
Cc: linux-pm, linux-kernel
On 12/06/2026 23:53, Rob Herring (Arm) wrote:
> 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(-)
>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-13 7:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-12 21:53 [PATCH] power: supply: Match DT value types Rob Herring (Arm)
2026-06-13 7:47 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox