Skip to content

Commit

Permalink
ACPI: Fix ACPI battery regression introduced by commit 558073
Browse files Browse the repository at this point in the history
Commit 558073d ("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>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Rafael J. Wysocki authored and Linus Torvalds committed Dec 5, 2008
1 parent 4857339 commit aaad077
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions drivers/acpi/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,17 @@ static int acpi_battery_get_property(struct power_supply *psy,
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;
Expand Down

0 comments on commit aaad077

Please sign in to comment.