power: supply: sc27xx: Fix the incorrect formula when converting capacity to coulomb...
authorBaolin Wang <baolin.wang@linaro.org>
Tue, 15 Jan 2019 10:32:36 +0000 (18:32 +0800)
committerSebastian Reichel <sre@kernel.org>
Wed, 23 Jan 2019 20:26:56 +0000 (21:26 +0100)
We should multiply the calibrated current data (cur_1000ma_adc) when
converting current capacity (mAh) to coulomb counter, which can get
an accurate coulomb counter from the fuel gauge controller.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/sc27xx_fuel_gauge.c

index 4926b8a..ea1349f 100644 (file)
@@ -731,7 +731,7 @@ static int sc27xx_fgu_cap_to_clbcnt(struct sc27xx_fgu_data *data, int capacity)
         * Convert current capacity (mAh) to coulomb counter according to the
         * formula: 1 mAh =3.6 coulomb.
         */
-       return DIV_ROUND_CLOSEST(cur_cap * 36, 10);
+       return DIV_ROUND_CLOSEST(cur_cap * 36 * data->cur_1000ma_adc, 10);
 }
 
 static int sc27xx_fgu_calibration(struct sc27xx_fgu_data *data)