power: supply: Reset err after not finding static battery
authorYassine Oudjana <y.oudjana@protonmail.com>
Tue, 29 Mar 2022 03:34:03 +0000 (03:34 +0000)
committerSebastian Reichel <sre@kernel.org>
Wed, 13 Apr 2022 10:05:22 +0000 (12:05 +0200)
Otherwise power_supply_get_battery_info always returns -ENODEV
on devices that do not have a static battery, even when a simple
battery is found.

Fixes: c8aee3f41cb8 ("power: supply: Static data for Samsung batteries")
Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/power_supply_core.c

index ea02c8dcd7484a1652238a1dc739ebb02056a56b..d925cb137e1268f38cc91b5b7988dd6273beac18 100644 (file)
@@ -604,6 +604,12 @@ int power_supply_get_battery_info(struct power_supply *psy,
        err = samsung_sdi_battery_get_info(&psy->dev, value, &info);
        if (!err)
                goto out_ret_pointer;
+       else if (err == -ENODEV)
+               /*
+                * Device does not have a static battery.
+                * Proceed to look for a simple battery.
+                */
+               err = 0;
 
        if (strcmp("simple-battery", value)) {
                err = -ENODEV;