Skip to content

Commit

Permalink
power: supply: max17042_battery: mAh readings depend on r_sns value
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jwrdegoede authored and sre committed May 1, 2017
1 parent 7bfc939 commit d7d15fc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/power/supply/max17042_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d7d15fc

Please sign in to comment.