diff options
author | Hans de Goede <hdegoede@redhat.com> | 2017-04-14 20:32:57 +0200 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2017-05-01 12:37:54 +0200 |
commit | 6d6b61eafca94146cedf7709974a7423df16a6f1 (patch) | |
tree | d98d1ca2114c4206747ea4b5248e6071adee9665 /drivers/power | |
parent | 2e015412a320e49aab4beaeb6262e93fdc0a42f2 (diff) | |
download | linux-6d6b61eafca94146cedf7709974a7423df16a6f1.tar.bz2 |
power: supply: max17042_battery: Add support for the CHARGE_NOW property
At least upower prefers the more precise charge_now sysfs value over
capacity and the max17042 has the info, so lets export it.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/supply/max17042_battery.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c index 3838f09e013c..3e19797fec4b 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -89,6 +89,7 @@ static enum power_supply_property max17042_battery_props[] = { POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, POWER_SUPPLY_PROP_CHARGE_FULL, + POWER_SUPPLY_PROP_CHARGE_NOW, POWER_SUPPLY_PROP_CHARGE_COUNTER, POWER_SUPPLY_PROP_TEMP, POWER_SUPPLY_PROP_TEMP_ALERT_MIN, @@ -324,6 +325,15 @@ static int max17042_get_property(struct power_supply *psy, do_div(data64, chip->pdata->r_sns); val->intval = data64; break; + case POWER_SUPPLY_PROP_CHARGE_NOW: + ret = regmap_read(map, MAX17042_RepCap, &data); + if (ret < 0) + return ret; + + data64 = data * 5000000ll; + do_div(data64, chip->pdata->r_sns); + val->intval = data64; + break; case POWER_SUPPLY_PROP_CHARGE_COUNTER: ret = regmap_read(map, MAX17042_QH, &data); if (ret < 0) |