* [PATCH] power: supply: Reset err after not finding static battery
@ 2022-03-29 3:34 Yassine Oudjana
2022-03-29 16:19 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Yassine Oudjana @ 2022-03-29 3:34 UTC (permalink / raw)
To: Sebastian Reichel; +Cc: Yassine Oudjana, Linus Walleij, linux-pm, linux-kernel
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>
---
drivers/power/supply/power_supply_core.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index ea02c8dcd748..d925cb137e12 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -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;
--
2.35.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] power: supply: Reset err after not finding static battery
2022-03-29 3:34 [PATCH] power: supply: Reset err after not finding static battery Yassine Oudjana
@ 2022-03-29 16:19 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2022-03-29 16:19 UTC (permalink / raw)
To: Yassine Oudjana; +Cc: Sebastian Reichel, linux-pm, linux-kernel
On Tue, Mar 29, 2022 at 5:34 AM Yassine Oudjana
<y.oudjana@protonmail.com> wrote:
> 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>
Quick and nice fix, thanks a lot!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-29 16:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 3:34 [PATCH] power: supply: Reset err after not finding static battery Yassine Oudjana
2022-03-29 16:19 ` Linus Walleij
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.