ds2760_battery: Fix calculation of time_to_empty_now
authorSven Neumann <s.neumann@raumfeld.com>
Fri, 12 Nov 2010 10:36:22 +0000 (11:36 +0100)
committerAnton Vorontsov <cbouatmailru@gmail.com>
Thu, 18 Nov 2010 13:56:15 +0000 (16:56 +0300)
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>
Cc: stable@kernel.org [2.6.32..2.6.36]
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
drivers/power/ds2760_battery.c

index b3c01c16a1640773ade9a1d09b813e9356c30c8b..11e1ac508e57903f3fb7aefc6303b2dd5ea970f9 100644 (file)
@@ -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