mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ACPI: battery: fix incorrect charging status when current is zero
@ 2026-01-29 14:48 Ata İlhan Köktürk
  2026-02-01 12:50 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Ata İlhan Köktürk @ 2026-01-29 14:48 UTC (permalink / raw)
  To: rafael; +Cc: lenb, linux-acpi, linux-kernel, Ata İlhan Köktürk

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 consumption (e.g., 18W
instead of 7W during browsing) and
broken battery remaining 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>
---
 drivers/acpi/battery.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 34181fa52..b4ba8085f 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -211,7 +211,13 @@ static int acpi_battery_get_property(struct power_supply *psy,
 		if (battery->state & ACPI_BATTERY_STATE_DISCHARGING)
 			val->intval = acpi_battery_handle_discharging(battery);
 		else if (battery->state & ACPI_BATTERY_STATE_CHARGING)
-			val->intval = POWER_SUPPLY_STATUS_CHARGING;
+			/* Check if we can fetch ACPI current info */
+			if (battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN &&
+				battery->rate_now == 0)
+				/* On charge but no current (0W/0mA) */
+				val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
+			else
+				val->intval = POWER_SUPPLY_STATUS_CHARGING;
 		else if (battery->state & ACPI_BATTERY_STATE_CHARGE_LIMITING)
 			val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
 		else if (acpi_battery_is_charged(battery))
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ACPI: battery: fix incorrect charging status when current is zero
  2026-01-29 14:48 [PATCH] ACPI: battery: fix incorrect charging status when current is zero Ata İlhan Köktürk
@ 2026-02-01 12:50 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2026-02-01 12:50 UTC (permalink / raw)
  To: Ata İlhan Köktürk; +Cc: rafael, lenb, linux-acpi, linux-kernel

On Thu, Jan 29, 2026 at 3:49 PM Ata İlhan Köktürk
<atailhan2006@gmail.com> wrote:
>
> 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 consumption (e.g., 18W
> instead of 7W during browsing) and
> broken battery remaining 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>
> ---
>  drivers/acpi/battery.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 34181fa52..b4ba8085f 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -211,7 +211,13 @@ static int acpi_battery_get_property(struct power_supply *psy,
>                 if (battery->state & ACPI_BATTERY_STATE_DISCHARGING)
>                         val->intval = acpi_battery_handle_discharging(battery);
>                 else if (battery->state & ACPI_BATTERY_STATE_CHARGING)
> -                       val->intval = POWER_SUPPLY_STATUS_CHARGING;
> +                       /* Check if we can fetch ACPI current info */
> +                       if (battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN &&
> +                               battery->rate_now == 0)
> +                               /* On charge but no current (0W/0mA) */
> +                               val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
> +                       else
> +                               val->intval = POWER_SUPPLY_STATUS_CHARGING;
>                 else if (battery->state & ACPI_BATTERY_STATE_CHARGE_LIMITING)
>                         val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
>                 else if (acpi_battery_is_charged(battery))
> --

Applied as 6.20/7.0 material, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-02-01 12:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-29 14:48 [PATCH] ACPI: battery: fix incorrect charging status when current is zero Ata İlhan Köktürk
2026-02-01 12:50 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®