Skip to content

Commit

Permalink
power: supply: cw2015: Add CHARGE_NOW support
Browse files Browse the repository at this point in the history
CHARGE_NOW is expected by some user software (such as waybar)
instead of 'CAPACITY', in order to correctly calculate remaining battery
life.

Signed-off-by: Martin Ashby <[email protected]>
Reviewed-by: Tobias Schramm <[email protected]>
Tested-by: Tobias Schramm <[email protected]>
Signed-off-by: Sebastian Reichel <[email protected]>
  • Loading branch information
MFAshby authored and sre committed Mar 6, 2021
1 parent c018b53 commit bf38410
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/power/supply/cw2015_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,11 @@ static int cw_battery_get_property(struct power_supply *psy,
val->intval = 0;
break;

case POWER_SUPPLY_PROP_CHARGE_NOW:
val->intval = cw_bat->battery.charge_full_design_uah;
val->intval = val->intval * cw_bat->soc / 100;
break;

case POWER_SUPPLY_PROP_CURRENT_NOW:
if (cw_battery_valid_time_to_empty(cw_bat) &&
cw_bat->battery.charge_full_design_uah > 0) {
Expand Down Expand Up @@ -542,6 +547,7 @@ static enum power_supply_property cw_battery_properties[] = {
POWER_SUPPLY_PROP_CHARGE_COUNTER,
POWER_SUPPLY_PROP_CHARGE_FULL,
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
POWER_SUPPLY_PROP_CHARGE_NOW,
POWER_SUPPLY_PROP_CURRENT_NOW,
};

Expand Down

0 comments on commit bf38410

Please sign in to comment.