linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] platform/x86: lenovo-hotkey: Handle missing hardware features gracefully
@ 2025-06-27 19:54 Armin Wolf
  2025-06-27 20:38 ` Kurt Borja
  0 siblings, 1 reply; 10+ messages in thread
From: Armin Wolf @ 2025-06-27 19:54 UTC (permalink / raw)
  To: xy-jackie, alireza.bestboyy, atescula
  Cc: mpearson-lenovo, hdegoede, ilpo.jarvinen, platform-driver-x86,
	linux-kernel

Not all devices support audio mute and microphone mute LEDs, so the
explicitly checks for hardware support while probing. However missing
hardware features are treated as errors, causing the driver so fail
probing on devices that do not support both LEDs.

Fix this by simply ignoring hardware features that are not present.
This way the driver will properly load on devices not supporting both
LEDs and will stop throwing error messages on devices with no LEDS
at all.

Reported-by: Andrei Tescula <atescula@gmail.com>
Closes: https://https://lore.kernel.org/platform-driver-x86/2eda8f9b-9421-4068-87ae-ccfd834649bc@gmail.com/
Reported-by: BEST8OY <alireza.bestboyy@gmail.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220271
Tested-by: BEST8OY <alireza.bestboyy@gmail.com>
Fixes: 61250669eaa9 ("platform/x86:lenovo-wmi-hotkey-utilities.c: Support for mic and audio mute LEDs")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 .../platform/x86/lenovo/wmi-hotkey-utilities.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/x86/lenovo/wmi-hotkey-utilities.c b/drivers/platform/x86/lenovo/wmi-hotkey-utilities.c
index 89153afd7015..44f489336199 100644
--- a/drivers/platform/x86/lenovo/wmi-hotkey-utilities.c
+++ b/drivers/platform/x86/lenovo/wmi-hotkey-utilities.c
@@ -127,21 +127,26 @@ static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, struct
 	else
 		return -EIO;
 
-	wpriv->cdev[led_type].max_brightness = LED_ON;
-	wpriv->cdev[led_type].flags = LED_CORE_SUSPENDRESUME;
-
 	switch (led_type) {
 	case MIC_MUTE:
+		/*
+		 * A missing hardware feature is not an error, so do not return
+		 * an error here.
+		 */
 		if (led_version != WMI_LUD_SUPPORT_MICMUTE_LED_VER)
-			return -EIO;
+			return 0;
 
 		wpriv->cdev[led_type].name = "platform::micmute";
 		wpriv->cdev[led_type].brightness_set_blocking = &lsh_wmi_micmute_led_set;
 		wpriv->cdev[led_type].default_trigger = "audio-micmute";
 		break;
 	case AUDIO_MUTE:
+		/*
+		 * A missing hardware feature is not an error, so do not return
+		 * an error here.
+		 */
 		if (led_version != WMI_LUD_SUPPORT_AUDIOMUTE_LED_VER)
-			return -EIO;
+			return 0;
 
 		wpriv->cdev[led_type].name = "platform::mute";
 		wpriv->cdev[led_type].brightness_set_blocking = &lsh_wmi_audiomute_led_set;
@@ -152,6 +157,9 @@ static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, struct
 		return -EINVAL;
 	}
 
+	wpriv->cdev[led_type].max_brightness = LED_ON;
+	wpriv->cdev[led_type].flags = LED_CORE_SUSPENDRESUME;
+
 	err = devm_led_classdev_register(dev, &wpriv->cdev[led_type]);
 	if (err < 0) {
 		dev_err(dev, "Could not register mute LED %d : %d\n", led_type, err);
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-07-08  6:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-27 19:54 [PATCH] platform/x86: lenovo-hotkey: Handle missing hardware features gracefully Armin Wolf
2025-06-27 20:38 ` Kurt Borja
2025-06-27 21:17   ` Armin Wolf
2025-06-27 21:29     ` Kurt Borja
2025-06-27 23:01       ` Armin Wolf
2025-06-29 20:36         ` Mark Pearson
2025-06-29 22:52           ` Armin Wolf
2025-07-07  3:03           ` [PATCH] platform/x86: lenovo-hotkey: Handle missing hardware featuresgracefully Jackie Dong
2025-07-07  9:22             ` Hans de Goede
2025-07-08  6:44               ` [PATCH] platform/x86: lenovo-hotkey: Handle missing hardwarefeaturesgracefully Jackie Dong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).