The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] platform/x86: asus-wmi: restore battery charge limit support
@ 2026-08-18 17:58 Luis Miguel Arias
  0 siblings, 0 replies; 2+ messages in thread
From: Luis Miguel Arias @ 2026-08-18 17:58 UTC (permalink / raw)
  To: corentin.chary, luke, denis.benato
  Cc: hansg, ilpo.jarvinen, platform-driver-x86, linux-kernel,
	Luis Miguel Arias

On ASUS systems where the charge threshold is supported through
ASUS_WMI_DEVID_RSOC, initializing charge_end_threshold to -1 causes
the sysfs attribute to return -ENODATA. This makes TLP consider
charge threshold support unavailable.

Initialize the cached threshold to 100 instead, allowing userspace
to set the desired threshold normally.

Tested on ASUS with TLP 1.8.0:

Before this change:
* charge_end_threshold = -1
* TLP reported no charge threshold support

After this change:
* TLP reports "charge threshold" as supported
* natacpi (asus_wmi) is active
* charge_control_end_threshold can be set to 80%

Signed-off-by: Luis Miguel Arias <luismiguel@godjango.dev>
---
 drivers/platform/x86/asus-wmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 80144c412..87363b198 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -1586,7 +1586,7 @@ static int asus_wmi_battery_add(struct power_supply *battery, struct acpi_batter
 	 * platforms retains it, therefore signal the threshold as unknown
 	 * until user explicitly sets it to a new value.
 	 */
-	charge_end_threshold = -1;
+	charge_end_threshold = 100;
 
 	return 0;
 }
-- 
2.47.3


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

* Re: [PATCH] platform/x86: asus-wmi: restore battery charge limit support
       [not found] <20260818174850.51457-1-luismi@gdcore.dev>
@ 2026-08-18 18:09 ` Denis Benato
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Benato @ 2026-08-18 18:09 UTC (permalink / raw)
  To: Luis Miguel Arias, corentin.chary, luke
  Cc: hansg, ilpo.jarvinen, platform-driver-x86, linux-kernel


On 8/18/26 19:48, Luis Miguel Arias wrote:
> On ASUS systems where the charge threshold is supported through
> ASUS_WMI_DEVID_RSOC, initializing charge_end_threshold to -1 causes
> the sysfs attribute to return -ENODATA. This makes TLP consider
> charge threshold support unavailable.
>
> Initialize the cached threshold to 100 instead, allowing userspace
> to set the desired threshold normally.
>
> Tested on ASUS with TLP 1.8.0:
>
> Before this change:
> * charge_end_threshold = -1
> * TLP reported no charge threshold support
>
> After this change:
> * TLP reports "charge threshold" as supported
> * natacpi (asus_wmi) is active
> * charge_control_end_threshold can be set to 80%
Hi Luis,

I'm confused here... I sent a temporary revert for this while we waited for
Upower to allow changing threshold with -ENODATA. The current version
of upower is fixed and I wasn't even aware TLP could do this: how do
you do it?

This means TLP also need to support -ENODATA properly and stop treating
it as an error... Do you want to contact them or do you want me to do it?

Anyway the main idea is that this is not the expected behavior and is
considered bad practice to change the limit at boot without user asking,
so I think the wise thing to do is for Ilpo to apply my temporary revert to
platform/x86 too while we wait for TLP to behave properly...

P.S. newer version should have v2. v3 etc...

Best regards,
Denis
> Signed-off-by: Luis Miguel Arias <luismi@gdcore.dev>
> ---
>  drivers/platform/x86/asus-wmi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 80144c412..87363b198 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -1586,7 +1586,7 @@ static int asus_wmi_battery_add(struct power_supply *battery, struct acpi_batter
>  	 * platforms retains it, therefore signal the threshold as unknown
>  	 * until user explicitly sets it to a new value.
>  	 */
> -	charge_end_threshold = -1;
> +	charge_end_threshold = 100;
>  
>  	return 0;
>  }

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

end of thread, other threads:[~2026-08-18 18:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260818174850.51457-1-luismi@gdcore.dev>
2026-08-18 18:09 ` [PATCH] platform/x86: asus-wmi: restore battery charge limit support Denis Benato
2026-08-18 17:58 Luis Miguel Arias

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