summaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorSebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>2020-11-25 05:47:04 +0100
committerSebastian Reichel <sre@kernel.org>2020-11-30 01:14:42 +0100
commit6dcfa009f8a96273f074032c888409ee2b26f498 (patch)
tree652fab7e03a584abe3b6a351ec2dd7ceeb5dd257 /drivers/power
parentpower: supply: max17042_battery: Improve accuracy of current_now and current_... (diff)
downloadlinux-6dcfa009f8a96273f074032c888409ee2b26f498.tar.xz
linux-6dcfa009f8a96273f074032c888409ee2b26f498.zip
power: supply: max17042_battery: Take r_sns value into account in charge_counter
The default r_sns value was hardcoded there, so let's change it to the actually configured one. Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/supply/max17042_battery.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 86adccb0f32d..26f6f89eb648 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -354,7 +354,8 @@ static int max17042_get_property(struct power_supply *psy,
if (ret < 0)
return ret;
- val->intval = data * 1000 / 2;
+ data64 = sign_extend64(data, 15) * 5000000ll;
+ val->intval = div_s64(data64, chip->pdata->r_sns);
break;
case POWER_SUPPLY_PROP_TEMP:
ret = max17042_get_temperature(chip, &val->intval);