aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/battery.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2008-12-04 19:07:51 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-12-05 00:43:16 -0500
commitaaad077638be1a25871bcae5e43952d6b63abfca (patch)
tree874d52d1b88a04f1a12ea1552a8be0ff82ff4e74 /drivers/acpi/battery.c
parent4857339d7c01cd81ce8872da2d1f9183b07b1c87 (diff)
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> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/acpi/battery.c')
-rw-r--r--drivers/acpi/battery.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index a0a178dd189c..4fb3c12ac1d8 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -173,14 +173,17 @@ static int acpi_battery_get_property(struct power_supply *psy,
173 val->intval = battery->voltage_now * 1000; 173 val->intval = battery->voltage_now * 1000;
174 break; 174 break;
175 case POWER_SUPPLY_PROP_CURRENT_NOW: 175 case POWER_SUPPLY_PROP_CURRENT_NOW:
176 val->intval = battery->current_now * 1000; 176 val->intval = battery->current_now;
177 /* if power units are mW, convert to mA by 177 if (battery->power_unit) {
178 dividing by current voltage (mV/1000) */ 178 val->intval *= 1000;
179 if (!battery->power_unit) { 179 } else {
180 if (battery->voltage_now) { 180 /*
181 * If power units are mW, convert to mA by dividing by
182 * current voltage.
183 */
184 if (battery->voltage_now)
181 val->intval /= battery->voltage_now; 185 val->intval /= battery->voltage_now;
182 val->intval *= 1000; 186 else
183 } else
184 val->intval = -1; 187 val->intval = -1;
185 } 188 }
186 break; 189 break;