]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
platform/x86: asus-wmi: do not enforce a battery charge threshold
authorDenis Benato <denis.benato@linux.dev>
Wed, 4 Mar 2026 13:26:08 +0000 (14:26 +0100)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 24 Mar 2026 13:26:10 +0000 (15:26 +0200)
Users are complaining for the battery limit being reset at 100% during
the boot process while the general consensus appears to not apply
unsolicited hardware changes, therefore stop resetting the battery
charge limit at boot and return -ENODATA on charge_end_threshold to
signal for an unknown limit.

Suggested-by: Antheas Kapenekakis <lkml@antheas.dev>
Suggested-by: Derek J. Clark <derekjohn.clark@gmail.com>
Signed-off-by: Denis Benato <denis.benato@linux.dev>
Reviewed-by: Derek J. Clark <derekjohn.clark@gmail.com>
Tested-by: Antheas Kapenekakis <lkml@antheas.dev>
Link: https://patch.msgid.link/20260304132608.33815-1-denis.benato@linux.dev
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/asus-wmi.c

index 6ba49bd375dfa6b48b80ca5628a927c27f3a5126..dc330a8ee2f23a5241024989e68225c6eb48d39c 100644 (file)
@@ -1557,7 +1557,10 @@ static ssize_t charge_control_end_threshold_show(struct device *device,
                                                 struct device_attribute *attr,
                                                 char *buf)
 {
-       return sysfs_emit(buf, "%d\n", charge_end_threshold);
+       if ((charge_end_threshold >= 0) && (charge_end_threshold <= 100))
+               return sysfs_emit(buf, "%d\n", charge_end_threshold);
+
+       return -ENODATA;
 }
 
 static DEVICE_ATTR_RW(charge_control_end_threshold);
@@ -1580,11 +1583,11 @@ static int asus_wmi_battery_add(struct power_supply *battery, struct acpi_batter
                return -ENODEV;
 
        /* The charge threshold is only reset when the system is power cycled,
-        * and we can't get the current threshold so let set it to 100% when
-        * a battery is added.
+        * and we can't read the current threshold, however the majority of
+        * platforms retains it, therefore signal the threshold as unknown
+        * until user explicitly sets it to a new value.
         */
-       asus_wmi_set_devstate(ASUS_WMI_DEVID_RSOC, 100, NULL);
-       charge_end_threshold = 100;
+       charge_end_threshold = -1;
 
        return 0;
 }