]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
platform/x86: asus-wmi: Support laptops where the first battery is named BATT
authorKristian Klausen <kristian@klausen.dk>
Tue, 3 Mar 2020 18:02:15 +0000 (19:02 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 5 May 2020 10:32:22 +0000 (12:32 +0200)
BugLink: https://bugs.launchpad.net/bugs/1873481
commit 6b3586d45bba14f6912f37488090c37a3710e7b4 upstream.

The WMI method to set the charge threshold does not provide a
way to specific a battery, so we assume it is the first/primary
battery (by checking if the name is BAT0).
On some newer ASUS laptops (Zenbook UM431DA) though, the
primary/first battery isn't named BAT0 but BATT, so we need
to support that case.

Fixes: 7973353e92ee ("platform/x86: asus-wmi: Refactor charge threshold to use the battery hooking API")
Cc: stable@vger.kernel.org
Signed-off-by: Kristian Klausen <kristian@klausen.dk>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
drivers/platform/x86/asus-wmi.c

index 982f0cc8270ce6ea6bd6f27addf3074e1bbb43ca..41e28552b2cea9484fa135531983a03298b496f1 100644 (file)
@@ -418,8 +418,11 @@ static int asus_wmi_battery_add(struct power_supply *battery)
 {
        /* The WMI method does not provide a way to specific a battery, so we
         * just assume it is the first battery.
+        * Note: On some newer ASUS laptops (Zenbook UM431DA), the primary/first
+        * battery is named BATT.
         */
-       if (strcmp(battery->desc->name, "BAT0") != 0)
+       if (strcmp(battery->desc->name, "BAT0") != 0 &&
+           strcmp(battery->desc->name, "BATT") != 0)
                return -ENODEV;
 
        if (device_create_file(&battery->dev,