]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.36.4/ds2760_battery-fix-calculation-of-time_to_empty_now.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.36.4 / ds2760_battery-fix-calculation-of-time_to_empty_now.patch
1 From 86af95039b69a90db15294eb1f9c147f1df0a8ea Mon Sep 17 00:00:00 2001
2 From: Sven Neumann <s.neumann@raumfeld.com>
3 Date: Fri, 12 Nov 2010 11:36:22 +0100
4 Subject: ds2760_battery: Fix calculation of time_to_empty_now
5
6 From: Sven Neumann <s.neumann@raumfeld.com>
7
8 commit 86af95039b69a90db15294eb1f9c147f1df0a8ea upstream.
9
10 A check against division by zero was modified in commit b0525b48.
11 Since this change time_to_empty_now is always reported as zero
12 while the battery is discharging and as a negative value while
13 the battery is charging. This is because current is negative while
14 the battery is discharging.
15
16 Fix the check introduced by commit b0525b48 so that time_to_empty_now
17 is reported correctly during discharge and as zero while charging.
18
19 Signed-off-by: Sven Neumann <s.neumann@raumfeld.com>
20 Acked-by: Daniel Mack <daniel@caiaq.de>
21 Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
23
24 ---
25 drivers/power/ds2760_battery.c | 2 +-
26 1 file changed, 1 insertion(+), 1 deletion(-)
27
28 --- a/drivers/power/ds2760_battery.c
29 +++ b/drivers/power/ds2760_battery.c
30 @@ -212,7 +212,7 @@ static int ds2760_battery_read_status(st
31 if (di->rem_capacity > 100)
32 di->rem_capacity = 100;
33
34 - if (di->current_uA >= 100L)
35 + if (di->current_uA < -100L)
36 di->life_sec = -((di->accum_current_uAh - di->empty_uAh) * 36L)
37 / (di->current_uA / 100L);
38 else