Skip to contentSkip to conversation

power: supply: core: Fix parsing of battery chemistry/technology

PATCH In review Dmitry Osipenko 3 participants 3 messages Aug 19, 2021 – Aug 20, 2021 Power supply

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 power: supply: core: Fix parsing of battery chemistry/technology

The power_supply_get_battery_info() fails if device-chemistry property is missing in a device-tree because error variable is propagated to the final return of the function, fix it.

Fixes 4eef766b7d4d ("power: supply: core: Parse battery chemistry/technology")
---
 drivers/power/supply/power_supply_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/power/supply/power_supply_core.c +1 -2
index dd62c871b2b5..0c2132c7f5d4 100644
@@ -619,8 +619,7 @@ int power_supply_get_battery_info(struct power_supply *psy,
 	 * Documentation/power/power_supply_class.rst.
 	 */
 
-	err = of_property_read_string(battery_np, "device-chemistry", &value);
-	if (!err) {
+	if (!of_property_read_string(battery_np, "device-chemistry", &value)) {
 		if (!strcmp("nickel-cadmium", value))
 			info->technology = POWER_SUPPLY_TECHNOLOGY_NiCd;
 		else if (!strcmp("nickel-metal-hydride", value))
Signature · 1 line
2.32.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dmitry Osipenko

The power_supply_get_battery_info() fails if device-chemistry property is missing in a device-tree because error variable is propagated to the final return of the function, fix it.

Fixes 4eef766b7d4d ("power: supply: core: Parse battery chemistry/technology")

Oops,

Yours,
Linus Walleij

#2 lore raw

Hi,

Quoted 11 lines · Linus Walleij
Quoted 6 lines · Dmitry Osipenko

The power_supply_get_battery_info() fails if device-chemistry property is missing in a device-tree because error variable is propagated to the final return of the function, fix it.

Fixes 4eef766b7d4d ("power: supply: core: Parse battery chemistry/technology")

Oops,

Thanks, queued.

-- Sebastian