Skip to content

Commit

Permalink
power: supply: bq27xxx: support missing supplier device
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Sebastian Reichel <[email protected]>
  • Loading branch information
sre committed Mar 12, 2018
1 parent 66ec32f commit f72c14a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/power/supply/bq27xxx_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f72c14a

Please sign in to comment.