]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
lenovo-wmi-hotkey: Avoid triggering error -5 due to missing mute LED
authorJackie Dong <xy-jackie@139.com>
Wed, 9 Jul 2025 03:57:16 +0000 (11:57 +0800)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Wed, 9 Jul 2025 08:49:20 +0000 (11:49 +0300)
Not all of Lenovo non-ThinkPad devices support both mic mute LED (on F4)
and audio mute LED (on F1). Some of them only support one mute LED, some
of them don't have any mute LEDs. If any of the mute LEDs is missing,
the driver reports error -5.

Check if the device supports a mute LED or not. Do not trigger error -5
message from missing a mute LED if it is not supported on the device.

Signed-off-by: Jackie Dong <xy-jackie@139.com>
Suggested-by: Hans de Goede <hansg@kernel.org>
Link: https://lore.kernel.org/r/20250709035716.36267-1-xy-jackie@139.com
[ij: major edits to the changelog.]
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c

index 89153afd701544c71244a108575b9cc6360e3abc..7b9bad1978ff20be6ba2d802a5c7d06390d08bf0 100644 (file)
@@ -122,26 +122,35 @@ static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, struct
                return -EIO;
 
        union acpi_object *obj __free(kfree) = output.pointer;
-       if (obj && obj->type == ACPI_TYPE_INTEGER)
-               led_version = obj->integer.value;
-       else
+       if (!obj || obj->type != ACPI_TYPE_INTEGER)
                return -EIO;
 
-       wpriv->cdev[led_type].max_brightness = LED_ON;
-       wpriv->cdev[led_type].flags = LED_CORE_SUSPENDRESUME;
+       led_version = obj->integer.value;
+
+       /*
+        * Output parameters define: 0 means mute LED is not supported, Non-zero means
+        * mute LED can be supported.
+        */
+       if (led_version == 0)
+               return 0;
+
 
        switch (led_type) {
        case MIC_MUTE:
-               if (led_version != WMI_LUD_SUPPORT_MICMUTE_LED_VER)
-                       return -EIO;
+               if (led_version != WMI_LUD_SUPPORT_MICMUTE_LED_VER) {
+                       pr_warn("The MIC_MUTE LED of this device isn't supported.\n");
+                       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:
-               if (led_version != WMI_LUD_SUPPORT_AUDIOMUTE_LED_VER)
-                       return -EIO;
+               if (led_version != WMI_LUD_SUPPORT_AUDIOMUTE_LED_VER) {
+                       pr_warn("The AUDIO_MUTE LED of this device isn't supported.\n");
+                       return 0;
+               }
 
                wpriv->cdev[led_type].name = "platform::mute";
                wpriv->cdev[led_type].brightness_set_blocking = &lsh_wmi_audiomute_led_set;
@@ -152,6 +161,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);