public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Len Brown <lenb@kernel.org>
Cc: ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Alexey Starikovskiy <astarikovskiy@suse.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH -regression fix] ACPI: Fix ACPI battery regression introduced by commit 558073
Date: Fri, 5 Dec 2008 01:07:51 +0100	[thread overview]
Message-ID: <200812050107.51343.rjw@sisk.pl> (raw)

From: Rafael J. Wysocki <rjw@sisk.pl>
Subject: ACPI: Fix ACPI battery regression introduced by commit 558073

Commit 558073dd56707864f09d563b64e7c37c021e89d2
"ACPI: battery: Convert discharge energy rate to current properly"
caused the battery subsystem to report wrong values of the remaining
time on battery power and the time until fully charged on Toshiba
Portege R500 (and presumably on other boxes too).

Fix the issue by correcting the conversion from mW to mA.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/acpi/battery.c |   17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

Index: linux-2.6/drivers/acpi/battery.c
===================================================================
--- linux-2.6.orig/drivers/acpi/battery.c
+++ linux-2.6/drivers/acpi/battery.c
@@ -173,14 +173,17 @@ static int acpi_battery_get_property(str
 		val->intval = battery->voltage_now * 1000;
 		break;
 	case POWER_SUPPLY_PROP_CURRENT_NOW:
-		val->intval = battery->current_now * 1000;
-		/* if power units are mW, convert to mA by
-		   dividing by current voltage (mV/1000) */
-		if (!battery->power_unit) {
-			if (battery->voltage_now) {
+		val->intval = battery->current_now;
+		if (battery->power_unit) {
+			val->intval *= 1000;
+		} else {
+			/*
+			 * If power units are mW, convert to mA by dividing by
+			 * current voltage.
+			 */
+			if (battery->voltage_now)
 				val->intval /= battery->voltage_now;
-				val->intval *= 1000;
-			} else
+			else
 				val->intval = -1;
 		}
 		break;

                 reply	other threads:[~2008-12-05  0:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200812050107.51343.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=akpm@linux-foundation.org \
    --cc=astarikovskiy@suse.de \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox