diff options
author | Arthur Demchenkov <spinal.by@gmail.com> | 2021-01-10 21:54:02 +0200 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2021-01-14 23:42:42 +0100 |
commit | 0f596487ff9910bc23ef7fd303fae7c23ee5f835 (patch) | |
tree | 7012ffdac0797ef374bdc013f2b256f35777d343 /drivers/power | |
parent | 1e64926c5dd978ae444d127b1414e6682b63733f (diff) | |
download | linux-0f596487ff9910bc23ef7fd303fae7c23ee5f835.tar.gz linux-0f596487ff9910bc23ef7fd303fae7c23ee5f835.tar.bz2 linux-0f596487ff9910bc23ef7fd303fae7c23ee5f835.zip |
power: supply: cpcap-battery: Add charge_now property
Add charge_now property for capacity reporting.
Cc: Arthur Demchenkov <spinal.by@gmail.com>
Cc: Carl Philipp Klemm <philipp@uvos.xyz>
Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Arthur Demchenkov <spinal.by@gmail.com>
[tony@atomide.com: updated to apply for naming changes]
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/supply/cpcap-battery.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c index bb27016f5906..be91339248c0 100644 --- a/drivers/power/supply/cpcap-battery.c +++ b/drivers/power/supply/cpcap-battery.c @@ -542,6 +542,7 @@ static enum power_supply_property cpcap_battery_props[] = { POWER_SUPPLY_PROP_CURRENT_AVG, POWER_SUPPLY_PROP_CURRENT_NOW, POWER_SUPPLY_PROP_CHARGE_FULL, + POWER_SUPPLY_PROP_CHARGE_NOW, POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, POWER_SUPPLY_PROP_CHARGE_COUNTER, POWER_SUPPLY_PROP_POWER_NOW, @@ -661,6 +662,16 @@ static int cpcap_battery_get_property(struct power_supply *psy, else val->intval = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN; break; + case POWER_SUPPLY_PROP_CHARGE_NOW: + empty = cpcap_battery_get_empty(ddata); + if (!empty->voltage) + return -ENODATA; + val->intval = empty->counter_uah - latest->counter_uah; + if (val->intval < 0) + val->intval = 0; + else if (ddata->charge_full && ddata->charge_full < val->intval) + val->intval = ddata->charge_full; + break; case POWER_SUPPLY_PROP_CHARGE_FULL: if (!ddata->charge_full) return -ENODATA; |