diff mbox series

platform/x86: asus-wmi: Consider device is absent when the read is ~0

Message ID 20240308053255.224496-1-kai.heng.feng@canonical.com (mailing list archive)
State Accepted, archived
Headers show
Series platform/x86: asus-wmi: Consider device is absent when the read is ~0 | expand

Commit Message

Kai-Heng Feng March 8, 2024, 5:32 a.m. UTC
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>
---
 drivers/platform/x86/asus-wmi.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Ilpo Järvinen March 8, 2024, 8:56 a.m. UTC | #1
On Fri, 8 Mar 2024, Kai-Heng Feng wrote:

> 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>
Ilpo Järvinen March 11, 2024, noon UTC | #2
On Fri, 08 Mar 2024 13:32:55 +0800, Kai-Heng Feng wrote:

> 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.
> 
> [...]


Thank you for your contribution, it has been applied to my local
review-ilpo branch. Note it will show up in the public
platform-drivers-x86/review-ilpo branch only once I've pushed my
local branch there, which might take a while.

The list of commits applied:
[1/1] platform/x86: asus-wmi: Consider device is absent when the read is ~0
      commit: 3f44cda7c36276f75d1ddcd2d52eb2d412e30cd0

--
 i.
diff mbox series

Patch

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 18be35fdb381..8cb2afafde16 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -489,7 +489,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,