ACPI: Fix ACPI battery regression introduced by commit 558073

Commit 558073dd56 ("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>
This commit is contained in:
Rafael J. Wysocki 2008-12-05 01:07:51 +01:00 коммит произвёл Linus Torvalds
Родитель 4857339d7c
Коммит aaad077638
1 изменённых файлов: 10 добавлений и 7 удалений

Просмотреть файл

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