summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorDmitry Osipenko <digetx@gmail.com>2021-08-20 02:51:11 +0300
committerSebastian Reichel <sebastian.reichel@collabora.com>2021-08-20 18:57:56 +0200
commitc9398455b046fc7a44b6dd53d9d6fe4b11c21700 (patch)
treec00524c38d9dd0e330118aa5af77af2dac68ffa7 /drivers/power
parenteaa2c490514d2d49c3ef1764530234d07f422289 (diff)
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") Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/supply/power_supply_core.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index dd62c871b2b5..0c2132c7f5d4 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -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))