aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Neumann <s.neumann@raumfeld.com>2010-11-12 11:36:22 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2011-02-17 15:14:26 -0800
commit39ed1e1ac83399b318f6b026d83fd01342422f23 (patch)
tree52e8820e15433ab1371a694bb174e95a5f2fa8fa
parentfcd8c1ff604201722610d43c01a1cf035e2ea273 (diff)
downloadlinux-hpc-39ed1e1ac83399b318f6b026d83fd01342422f23.tar.gz
ds2760_battery: Fix calculation of time_to_empty_now
commit 86af95039b69a90db15294eb1f9c147f1df0a8ea upstream. A check against division by zero was modified in commit b0525b48. Since this change time_to_empty_now is always reported as zero while the battery is discharging and as a negative value while the battery is charging. This is because current is negative while the battery is discharging. Fix the check introduced by commit b0525b48 so that time_to_empty_now is reported correctly during discharge and as zero while charging. Signed-off-by: Sven Neumann <s.neumann@raumfeld.com> Acked-by: Daniel Mack <daniel@caiaq.de> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/power/ds2760_battery.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/power/ds2760_battery.c b/drivers/power/ds2760_battery.c
index b3c01c16a16407..11e1ac508e5790 100644
--- a/drivers/power/ds2760_battery.c
+++ b/drivers/power/ds2760_battery.c
@@ -212,7 +212,7 @@ static int ds2760_battery_read_status(struct ds2760_device_info *di)
if (di->rem_capacity > 100)
di->rem_capacity = 100;
- if (di->current_uA >= 100L)
+ if (di->current_uA < -100L)
di->life_sec = -((di->accum_current_uAh - di->empty_uAh) * 36L)
/ (di->current_uA / 100L);
else