]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
power: supply: max17040: Correct voltage reading
authorJonathan Bakker <xc-racer2@live.ca>
Mon, 4 May 2020 22:12:58 +0000 (15:12 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Oct 2020 11:17:59 +0000 (13:17 +0200)
[ Upstream commit 0383024f811aa469df258039807810fc3793a105 ]

According to the datasheet available at (1), the bottom four
bits are always zero and the actual voltage is 1.25x this value
in mV.  Since the kernel API specifies that voltages should be in
uV, it should report 1250x the shifted value.

1) https://datasheets.maximintegrated.com/en/ds/MAX17040-MAX17041.pdf

Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/power/supply/max17040_battery.c

index 62499018e68bf66dcfef11587b6c3084efb8a549..2e845045a3fc0f4dee52f4b4bed2f7ecb55e7031 100644 (file)
@@ -105,7 +105,7 @@ static void max17040_get_vcell(struct i2c_client *client)
 
        vcell = max17040_read_reg(client, MAX17040_VCELL);
 
-       chip->vcell = vcell;
+       chip->vcell = (vcell >> 4) * 1250;
 }
 
 static void max17040_get_soc(struct i2c_client *client)