aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/supply
diff options
context:
space:
mode:
authorMartin Ashby <martin@ashbysoft.com>2021-02-18 07:42:50 -0500
committerSebastian Reichel <sre@kernel.org>2021-03-06 18:39:05 +0100
commitbf3841073bf34c9568ee5d6a6020b3902b3eef81 (patch)
tree696214b381f580b9054e089573d813b90680775b /drivers/power/supply
parentpower: supply: max8997-charger: remove unneeded semicolon (diff)
downloadlinux-dev-bf3841073bf34c9568ee5d6a6020b3902b3eef81.tar.xz
linux-dev-bf3841073bf34c9568ee5d6a6020b3902b3eef81.zip
power: supply: cw2015: Add CHARGE_NOW support
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 <martin@ashbysoft.com> Reviewed-by: Tobias Schramm <t.schramm@manjaro.org> Tested-by: Tobias Schramm <t.schramm@manjaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power/supply')
-rw-r--r--drivers/power/supply/cw2015_battery.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/power/supply/cw2015_battery.c b/drivers/power/supply/cw2015_battery.c
index 0146f1bfc29b..d110597746b0 100644
--- a/drivers/power/supply/cw2015_battery.c
+++ b/drivers/power/supply/cw2015_battery.c
@@ -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) {
@@ -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,
};