Skip to content

Commit

Permalink
power: supply: bq27xxx: report "not charging" on all types
Browse files Browse the repository at this point in the history
[ Upstream commit 7bf738b ]

Commit 6f24ff9 ("power: supply: bq27xxx_battery: Add the
BQ27Z561 Battery monitor") and commit d74534c ("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>
  • Loading branch information
krzk authored and gregkh committed Nov 5, 2020
1 parent 036b0f4 commit a10ed3b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/power/supply/bq27xxx_battery.c
Expand Up @@ -1678,8 +1678,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 {
Expand All @@ -1691,6 +1689,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;
Expand Down

0 comments on commit a10ed3b

Please sign in to comment.