power: supply: Match DT value types
Subsystems (2)
PATCH 1/1 power: supply: Match DT value types
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.
--- drivers/power/supply/ltc2941-battery-gauge.c | 2 +- drivers/power/supply/max17042_battery.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/power/supply/ltc2941-battery-gauge.c +1 -1
@@ -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" );
drivers/power/supply/max17042_battery.c +6 -2
@@ -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; }
Signature · 1 line
2.53.0
Quoted 8 lines · Rob Herring (Arm)
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.
Quoted 7 lines
Assisted-by Codex:gpt-5-5Signed-off-by Rob Herring (Arm) <[email protected]>--- drivers/power/supply/ltc2941-battery-gauge.c | 2 +- drivers/power/supply/max17042_battery.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-)
Best regards,
Krzysztof