Skip to contentSkip to conversation

power: supply: Match DT value types

PATCH In review Rob Herring (Arm) 2 participants 2 messages Jun 12 – Jun 13

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

Assisted-by Codex:gpt-5-5
---
 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
index a1ddc4b060ce..83cca11e92f6 100644
@@ -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
index 167fb3fb3732..6609cd74e5d3 100644
@@ -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
reviewer Reviewed-by on v1 1/1
#1 lore raw
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-5
---
 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