From patchwork Mon Apr 8 03:33:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 1920646 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VCZT0207sz1yYT for ; Mon, 8 Apr 2024 13:34:11 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rtflf-0004xT-9O; Mon, 08 Apr 2024 03:33:59 +0000 Received: from smtp-relay-canonical-1.internal ([10.131.114.174] helo=smtp-relay-canonical-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rtfld-0004wx-Sy for kernel-team@lists.ubuntu.com; Mon, 08 Apr 2024 03:33:57 +0000 Received: from localhost.localdomain (unknown [10.101.196.174]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id F05063F139 for ; Mon, 8 Apr 2024 03:33:55 +0000 (UTC) From: Kai-Heng Feng To: kernel-team@lists.ubuntu.com Subject: [J/M/N] [PATCH 1/1] platform/x86: asus-wmi: Consider device is absent when the read is ~0 Date: Mon, 8 Apr 2024 11:33:10 +0800 Message-Id: <20240408033310.1188408-2-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240408033310.1188408-1-kai.heng.feng@canonical.com> References: <20240408033310.1188408-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/2060422 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 Reviewed-by: Ilpo Järvinen Link: https://lore.kernel.org/r/20240308053255.224496-1-kai.heng.feng@canonical.com Signed-off-by: Ilpo Järvinen (cherry picked from commit f7b7066508d69934e4545db0c709c98ce506df0c) Signed-off-by: Kai-Heng Feng --- drivers/platform/x86/asus-wmi.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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,