Commit 6d6b61ea authored by Hans de Goede's avatar Hans de Goede Committed by Sebastian Reichel

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: default avatarHans de Goede <hdegoede@redhat.com>
Reviewed-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.co.uk>
parent 2e015412
...@@ -89,6 +89,7 @@ static enum power_supply_property max17042_battery_props[] = { ...@@ -89,6 +89,7 @@ static enum power_supply_property max17042_battery_props[] = {
POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_CAPACITY,
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
POWER_SUPPLY_PROP_CHARGE_FULL, POWER_SUPPLY_PROP_CHARGE_FULL,
POWER_SUPPLY_PROP_CHARGE_NOW,
POWER_SUPPLY_PROP_CHARGE_COUNTER, POWER_SUPPLY_PROP_CHARGE_COUNTER,
POWER_SUPPLY_PROP_TEMP, POWER_SUPPLY_PROP_TEMP,
POWER_SUPPLY_PROP_TEMP_ALERT_MIN, POWER_SUPPLY_PROP_TEMP_ALERT_MIN,
...@@ -320,6 +321,15 @@ static int max17042_get_property(struct power_supply *psy, ...@@ -320,6 +321,15 @@ static int max17042_get_property(struct power_supply *psy,
if (ret < 0) if (ret < 0)
return ret; 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; data64 = data * 5000000ll;
do_div(data64, chip->pdata->r_sns); do_div(data64, chip->pdata->r_sns);
val->intval = data64; val->intval = data64;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment