diff options
author | Paer-Olof Haakansson <par-olof.hakansson@stericsson.com> | 2013-01-11 08:13:05 -0500 |
---|---|---|
committer | Anton Vorontsov <anton@enomsg.org> | 2013-01-15 20:44:44 -0500 |
commit | f902dadc123376b973e5f9cb216a22675a2a9181 (patch) | |
tree | 57120e6d0891005a173dc1b37d53cd19e805ad77 /drivers/power | |
parent | 4b45f4a9cd4eae34b23becb686f2c2a637d844d3 (diff) |
ab8500_fg: Overflow in current calculation
When calculating the average current the nominator will
overflow when the charging current is high.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Henrik Sölver <henrik.solver@stericsson.com>
Reviewed-by: Par-Olof HAKANSSON <par-olof.hakansson@stericsson.com>
Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
Tested-by: Par-Olof HAKANSSON <par-olof.hakansson@stericsson.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/ab8500_fg.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c index 2917def7621c..570577c32ade 100644 --- a/drivers/power/ab8500_fg.c +++ b/drivers/power/ab8500_fg.c | |||
@@ -805,12 +805,9 @@ static void ab8500_fg_acc_cur_work(struct work_struct *work) | |||
805 | 805 | ||
806 | /* | 806 | /* |
807 | * Convert to unit value in mA | 807 | * Convert to unit value in mA |
808 | * Full scale input voltage is | 808 | * by dividing by the conversion |
809 | * 66.660mV => LSB = 66.660mV/(4096*res) = 1.627mA | ||
810 | * Given a 250ms conversion cycle time the LSB corresponds | ||
811 | * to 112.9 nAh. Convert to current by dividing by the conversion | ||
812 | * time in hours (= samples / (3600 * 4)h) | 809 | * time in hours (= samples / (3600 * 4)h) |
813 | * 112.9nAh assumes 10mOhm, but fg_res is in 0.1mOhm | 810 | * and multiply with 1000 |
814 | */ | 811 | */ |
815 | di->avg_curr = (val * QLSB_NANO_AMP_HOURS_X10 * 36) / | 812 | di->avg_curr = (val * QLSB_NANO_AMP_HOURS_X10 * 36) / |
816 | (1000 * di->bm->fg_res * (di->fg_samples / 4)); | 813 | (1000 * di->bm->fg_res * (di->fg_samples / 4)); |
@@ -821,6 +818,8 @@ static void ab8500_fg_acc_cur_work(struct work_struct *work) | |||
821 | 818 | ||
822 | queue_work(di->fg_wq, &di->fg_work); | 819 | queue_work(di->fg_wq, &di->fg_work); |
823 | 820 | ||
821 | dev_dbg(di->dev, "fg_res: %d, fg_samples: %d, gasg: %d, accu_charge: %d \n", | ||
822 | di->bm->fg_res, di->fg_samples, val, di->accu_charge); | ||
824 | return; | 823 | return; |
825 | exit: | 824 | exit: |
826 | dev_err(di->dev, | 825 | dev_err(di->dev, |