power: supply: bq27xxx: support missing supplier device
authorSebastian Reichel <sebastian.reichel@collabora.co.uk>
Thu, 15 Feb 2018 20:28:40 +0000 (21:28 +0100)
committerSebastian Reichel <sre@kernel.org>
Mon, 12 Mar 2018 13:30:09 +0000 (14:30 +0100)
power_supply_am_i_supplied() can return negative error
codes. In this case we should assume, that no charger
is connected and the battery should be marked as
DISCHARGING instead of NOT_CHARGING.

Reported-by: Merlijn Wajer <merlijn@wizzup.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
drivers/power/supply/bq27xxx_battery.c

index d999815..7ce6051 100644 (file)
@@ -1670,7 +1670,7 @@ 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))
+               else if (power_supply_am_i_supplied(di->bat) > 0)
                        status = POWER_SUPPLY_STATUS_NOT_CHARGING;
                else
                        status = POWER_SUPPLY_STATUS_DISCHARGING;