Skip to content

Commit

Permalink
power: supply: Reset err after not finding static battery
Browse files Browse the repository at this point in the history
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: c8aee3f ("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>
  • Loading branch information
Yassine Oudjana authored and Sebastian Reichel committed Apr 13, 2022
1 parent 5c7d28c commit 581045e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/power/supply/power_supply_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 581045e

Please sign in to comment.