Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aaad0776 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Linus Torvalds
Browse files

ACPI: Fix ACPI battery regression introduced by commit 558073



Commit 558073dd ("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: default avatarRafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 4857339d
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -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->voltage_now;
		val->intval = battery->current_now;
		if (battery->power_unit) {
			val->intval *= 1000;
			} else
		} else {
			/*
			 * If power units are mW, convert to mA by dividing by
			 * current voltage.
			 */
			if (battery->voltage_now)
				val->intval /= battery->voltage_now;
			else
				val->intval = -1;
		}
		break;