diff mbox series

[v1] power: supply: core: Fix parsing of battery chemistry/technology

Message ID 20210819235111.25357-1-digetx@gmail.com
State Accepted
Commit c9398455b046fc7a44b6dd53d9d6fe4b11c21700
Headers show
Series [v1] power: supply: core: Fix parsing of battery chemistry/technology | expand

Commit Message

Dmitry Osipenko Aug. 19, 2021, 11:51 p.m. UTC
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>
---
 drivers/power/supply/power_supply_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Linus Walleij Aug. 20, 2021, 1:41 p.m. UTC | #1
On Fri, Aug 20, 2021 at 1:51 AM Dmitry Osipenko <digetx@gmail.com> wrote:

> 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>


Oops,
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>


Yours,
Linus Walleij
Sebastian Reichel Aug. 20, 2021, 4:59 p.m. UTC | #2
Hi,

On Fri, Aug 20, 2021 at 03:41:56PM +0200, Linus Walleij wrote:
> On Fri, Aug 20, 2021 at 1:51 AM Dmitry Osipenko <digetx@gmail.com> wrote:

> 

> > 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>

> 

> Oops,

> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>


Thanks, queued.

-- Sebastian
diff mbox series

Patch

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))