Message ID | 20170414183259.24382-12-hdegoede@redhat.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
On Fri, Apr 14, 2017 at 08:32:57PM +0200, Hans de Goede wrote: > Atleast upower prefers the more precise charge_now sysfs value over s/Atleast/At least/ ? Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Best regards, Krzysztof > capacity and the max17042 has the info, so lets export it. > > Signed-off-by: Hans de Goede <hdegoede@redhat.com> > --- > Changes in v2: > -Take r_sns value into account when converting the register value to uAh > --- > drivers/power/supply/max17042_battery.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) >
Hi, On Fri, Apr 14, 2017 at 08:32:57PM +0200, Hans de Goede wrote: > Atleast 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> Thanks, queued. -- Sebastian
diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c index 39b0f86..e80ff90 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)
Atleast 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> --- Changes in v2: -Take r_sns value into account when converting the register value to uAh --- drivers/power/supply/max17042_battery.c | 10 ++++++++++ 1 file changed, 10 insertions(+)