mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ds2760_battery: fix calculation of time_to_empty_now
@ 2010-11-12 10:36 Sven Neumann
  2010-11-18 13:58 ` Anton Vorontsov
  0 siblings, 1 reply; 2+ messages in thread
From: Sven Neumann @ 2010-11-12 10:36 UTC (permalink / raw)
  To: LKML; +Cc: Anton Vorontsov, David Woodhouse, Sven Neumann

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>
---
 drivers/power/ds2760_battery.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/power/ds2760_battery.c b/drivers/power/ds2760_battery.c
index 4d3b272..c8d26df 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
-- 
1.7.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ds2760_battery: fix calculation of time_to_empty_now
  2010-11-12 10:36 [PATCH] ds2760_battery: fix calculation of time_to_empty_now Sven Neumann
@ 2010-11-18 13:58 ` Anton Vorontsov
  0 siblings, 0 replies; 2+ messages in thread
From: Anton Vorontsov @ 2010-11-18 13:58 UTC (permalink / raw)
  To: Sven Neumann; +Cc: LKML, David Woodhouse

On Fri, Nov 12, 2010 at 11:36:22AM +0100, Sven Neumann wrote:
> 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>

Applied (with Cc: stable@kernel.org [2.6.32..2.6.36]).

Thanks!

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-11-18 13:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-12 10:36 [PATCH] ds2760_battery: fix calculation of time_to_empty_now Sven Neumann
2010-11-18 13:58 ` Anton Vorontsov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®