Skip to content

Commit bb1256e

Browse files
atailh4nrafaeljw
authored andcommitted
ACPI: battery: fix incorrect charging status when current is zero
On some laptops, such as the Huawei Matebook series, the embedded controller continues to report "Charging" status even when the charge threshold is reached and no current is being drawn. This incorrect reporting prevents the system from switching to battery power profiles, leading to significantly higher power (e.g., 18W instead of 7W during browsing) and missed remaining battery time estimation. Validate the "Charging" state by checking if rate_now is zero. If the hardware reports charging but the current is zero, report "Not Charging" to user space. Signed-off-by: Ata İlhan Köktürk <atailhan2006@gmail.com> [ rjw: Whitespace fix, braces added to an inner if (), new comment rewrite ] [ rjw: Changelog edits ] Link: https://patch.msgid.link/20260129144856.43058-1-atailhan2006@gmail.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 0a86940 commit bb1256e

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

drivers/acpi/battery.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,14 @@ static int acpi_battery_get_property(struct power_supply *psy,
212212
if (battery->state & ACPI_BATTERY_STATE_DISCHARGING)
213213
val->intval = acpi_battery_handle_discharging(battery);
214214
else if (battery->state & ACPI_BATTERY_STATE_CHARGING)
215-
val->intval = POWER_SUPPLY_STATUS_CHARGING;
215+
/* Validate the status by checking the current. */
216+
if (battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN &&
217+
battery->rate_now == 0) {
218+
/* On charge but no current (0W/0mA). */
219+
val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
220+
} else {
221+
val->intval = POWER_SUPPLY_STATUS_CHARGING;
222+
}
216223
else if (battery->state & ACPI_BATTERY_STATE_CHARGE_LIMITING)
217224
val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
218225
else if (acpi_battery_is_charged(battery))

0 commit comments

Comments
 (0)