]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
power: supply: max17042_battery: Add support for the CHARGE_NOW property
authorHans de Goede <hdegoede@redhat.com>
Fri, 14 Apr 2017 18:32:57 +0000 (20:32 +0200)
committerSebastian Reichel <sre@kernel.org>
Mon, 1 May 2017 10:37:54 +0000 (12:37 +0200)
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>
drivers/power/supply/max17042_battery.c

index 3838f09e013cac0bed8eb86d099755c62d075800..3e19797fec4b98efb7e749dbfdca8f5d1528c13c 100644 (file)
@@ -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,
@@ -320,6 +321,15 @@ static int max17042_get_property(struct power_supply *psy,
                if (ret < 0)
                        return ret;
 
+               data64 = data * 5000000ll;
+               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;