power: supply: max17042_battery: Take r_sns value into account in charge_counter
authorSebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>
Wed, 25 Nov 2020 04:47:04 +0000 (05:47 +0100)
committerSebastian Reichel <sre@kernel.org>
Mon, 30 Nov 2020 00:14:42 +0000 (01:14 +0100)
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>
drivers/power/supply/max17042_battery.c

index 86adccb0f32dde0d921379120bf46db5367ed27e..26f6f89eb64860c4e1ea108e48c8960dfb1731e2 100644 (file)
@@ -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);