diff options
author | Kai-Heng Feng <kai.heng.feng@canonical.com> | 2024-03-08 13:32:55 +0800 |
---|---|---|
committer | Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> | 2024-03-12 12:55:57 +0200 |
commit | f7b7066508d69934e4545db0c709c98ce506df0c (patch) | |
tree | df0f1048c74b714b315745428ae0571a520e5eee | |
parent | e9df5436fd61c8cf375ac086d936f90385cd6888 (diff) | |
download | linux-f7b7066508d69934e4545db0c709c98ce506df0c.tar.gz linux-f7b7066508d69934e4545db0c709c98ce506df0c.tar.bz2 linux-f7b7066508d69934e4545db0c709c98ce506df0c.zip |
platform/x86: asus-wmi: Consider device is absent when the read is ~0
AAEON PICO-TGU4 board doesn't have any LED but there are bogus LED
controls under /sys/class/leds:
$ ls /sys/class/leds
asus::kbd_backlight asus::lightbar platform::micmute
The reason is that the ~0 read from asus_wmi_get_devstate() is treated
as a valid state, in truth it means the device is absent.
So filter out ~0 read to prevent bogus LED controls being created.
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240308053255.224496-1-kai.heng.feng@canonical.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
-rw-r--r-- | drivers/platform/x86/asus-wmi.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 2865af89e95c..3f07bbf809ef 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -481,7 +481,17 @@ static int asus_wmi_evaluate_method_agfn(const struct acpi_buffer args) static int asus_wmi_get_devstate(struct asus_wmi *asus, u32 dev_id, u32 *retval) { - return asus_wmi_evaluate_method(asus->dsts_id, dev_id, 0, retval); + int err; + + err = asus_wmi_evaluate_method(asus->dsts_id, dev_id, 0, retval); + + if (err) + return err; + + if (*retval == ~0) + return -ENODEV; + + return 0; } static int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, |