summaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2017-04-14 20:32:55 +0200
committerSebastian Reichel <sre@kernel.org>2017-05-01 12:37:45 +0200
commitd7d15fc67791c0e255f36345d02441c1716c2a1f (patch)
tree8f45d2f7dfc748186ff588065a41667a918b132c /drivers/power
parent7bfc9397ff9690fbb0da44e1a0aeab953cb73b77 (diff)
downloadlinux-d7d15fc67791c0e255f36345d02441c1716c2a1f.tar.bz2
power: supply: max17042_battery: mAh readings depend on r_sns value
The PROP_CHARGE_FULL code was hardcoded for the default sense resistor of 0.010 Ohm, make it use r_sns which contains the actual sense resistor value in micro-Ohms instead. 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.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 0e94349b3855..37e987f55833 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -220,6 +220,7 @@ static int max17042_get_property(struct power_supply *psy,
struct regmap *map = chip->regmap;
int ret;
u32 data;
+ u64 data64;
if (!chip->init_complete)
return -EAGAIN;
@@ -309,7 +310,9 @@ static int max17042_get_property(struct power_supply *psy,
if (ret < 0)
return ret;
- val->intval = data * 1000 / 2;
+ 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);