aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/ds2760_battery.c
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2009-03-25 18:31:35 +0000
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-03-25 18:31:35 +0000
commit8937b7349ca9e25a02b2a72ccb7fba404ddedc5b (patch)
tree434ffe23d318f8af55850a26c3431ce8b82ab6f4 /drivers/power/ds2760_battery.c
parent997302259f386bca8fe1db67c50296ca426c438f (diff)
parentffe7f95bb1a4d1e9ca5d252445dc38476e1a208e (diff)
downloadkernel_samsung_smdk4412-8937b7349ca9e25a02b2a72ccb7fba404ddedc5b.zip
kernel_samsung_smdk4412-8937b7349ca9e25a02b2a72ccb7fba404ddedc5b.tar.gz
kernel_samsung_smdk4412-8937b7349ca9e25a02b2a72ccb7fba404ddedc5b.tar.bz2
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6 into devel
Diffstat (limited to 'drivers/power/ds2760_battery.c')
-rw-r--r--drivers/power/ds2760_battery.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/power/ds2760_battery.c b/drivers/power/ds2760_battery.c
index 1d76892..a52d4a1 100644
--- a/drivers/power/ds2760_battery.c
+++ b/drivers/power/ds2760_battery.c
@@ -180,10 +180,13 @@ static int ds2760_battery_read_status(struct ds2760_device_info *di)
di->empty_uAh = battery_interpolate(scale, di->temp_C / 10);
di->empty_uAh *= 1000; /* convert to µAh */
- /* From Maxim Application Note 131: remaining capacity =
- * ((ICA - Empty Value) / (Full Value - Empty Value)) x 100% */
- di->rem_capacity = ((di->accum_current_uAh - di->empty_uAh) * 100L) /
- (di->full_active_uAh - di->empty_uAh);
+ if (di->full_active_uAh == di->empty_uAh)
+ di->rem_capacity = 0;
+ else
+ /* From Maxim Application Note 131: remaining capacity =
+ * ((ICA - Empty Value) / (Full Value - Empty Value)) x 100% */
+ di->rem_capacity = ((di->accum_current_uAh - di->empty_uAh) * 100L) /
+ (di->full_active_uAh - di->empty_uAh);
if (di->rem_capacity < 0)
di->rem_capacity = 0;