]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
power: supply: bq27xxx: report "not charging" on all types
authorKrzysztof Kozlowski <krzk@kernel.org>
Sat, 19 Sep 2020 14:04:14 +0000 (16:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Nov 2020 10:51:15 +0000 (11:51 +0100)
[ Upstream commit 7bf738ba110722b63e9dc8af760d3fb2aef25593 ]

Commit 6f24ff97e323 ("power: supply: bq27xxx_battery: Add the
BQ27Z561 Battery monitor") and commit d74534c27775 ("power:
bq27xxx_battery: Add support for additional bq27xxx family devices")
added support for new device types by copying most of the code and
adding necessary quirks.

However they did not copy the code in bq27xxx_battery_status()
responsible for returning POWER_SUPPLY_STATUS_NOT_CHARGING.

Unify the bq27xxx_battery_status() so for all types when charger is
supplied, it will return "not charging" status.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/power/supply/bq27xxx_battery.c

index a123f6e21f08a8f05800dda7dcae9f323b1fc066..08b9d025a3e8172bd04269766ffff747a36a7583 100644 (file)
@@ -1772,8 +1772,6 @@ static int bq27xxx_battery_status(struct bq27xxx_device_info *di,
                        status = POWER_SUPPLY_STATUS_FULL;
                else if (di->cache.flags & BQ27000_FLAG_CHGS)
                        status = POWER_SUPPLY_STATUS_CHARGING;
-               else if (power_supply_am_i_supplied(di->bat) > 0)
-                       status = POWER_SUPPLY_STATUS_NOT_CHARGING;
                else
                        status = POWER_SUPPLY_STATUS_DISCHARGING;
        } else if (di->opts & BQ27Z561_O_BITS) {
@@ -1792,6 +1790,10 @@ static int bq27xxx_battery_status(struct bq27xxx_device_info *di,
                        status = POWER_SUPPLY_STATUS_CHARGING;
        }
 
+       if ((status == POWER_SUPPLY_STATUS_DISCHARGING) &&
+           (power_supply_am_i_supplied(di->bat) > 0))
+               status = POWER_SUPPLY_STATUS_NOT_CHARGING;
+
        val->intval = status;
 
        return 0;