Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lenovo-wmi-hotkey: Avoid triggering error -5 due to missing mute LED

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>

authored by

Jackie Dong and committed by
Ilpo Järvinen
c86f7bb9 e1098107

+21 -9
+21 -9
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c
··· 122 122 return -EIO; 123 123 124 124 union acpi_object *obj __free(kfree) = output.pointer; 125 - if (obj && obj->type == ACPI_TYPE_INTEGER) 126 - led_version = obj->integer.value; 127 - else 125 + if (!obj || obj->type != ACPI_TYPE_INTEGER) 128 126 return -EIO; 129 127 130 - wpriv->cdev[led_type].max_brightness = LED_ON; 131 - wpriv->cdev[led_type].flags = LED_CORE_SUSPENDRESUME; 128 + led_version = obj->integer.value; 129 + 130 + /* 131 + * Output parameters define: 0 means mute LED is not supported, Non-zero means 132 + * mute LED can be supported. 133 + */ 134 + if (led_version == 0) 135 + return 0; 136 + 132 137 133 138 switch (led_type) { 134 139 case MIC_MUTE: 135 - if (led_version != WMI_LUD_SUPPORT_MICMUTE_LED_VER) 136 - return -EIO; 140 + if (led_version != WMI_LUD_SUPPORT_MICMUTE_LED_VER) { 141 + pr_warn("The MIC_MUTE LED of this device isn't supported.\n"); 142 + return 0; 143 + } 137 144 138 145 wpriv->cdev[led_type].name = "platform::micmute"; 139 146 wpriv->cdev[led_type].brightness_set_blocking = &lsh_wmi_micmute_led_set; 140 147 wpriv->cdev[led_type].default_trigger = "audio-micmute"; 141 148 break; 142 149 case AUDIO_MUTE: 143 - if (led_version != WMI_LUD_SUPPORT_AUDIOMUTE_LED_VER) 144 - return -EIO; 150 + if (led_version != WMI_LUD_SUPPORT_AUDIOMUTE_LED_VER) { 151 + pr_warn("The AUDIO_MUTE LED of this device isn't supported.\n"); 152 + return 0; 153 + } 145 154 146 155 wpriv->cdev[led_type].name = "platform::mute"; 147 156 wpriv->cdev[led_type].brightness_set_blocking = &lsh_wmi_audiomute_led_set; ··· 160 151 dev_err(dev, "Unknown LED type %d\n", led_type); 161 152 return -EINVAL; 162 153 } 154 + 155 + wpriv->cdev[led_type].max_brightness = LED_ON; 156 + wpriv->cdev[led_type].flags = LED_CORE_SUSPENDRESUME; 163 157 164 158 err = devm_led_classdev_register(dev, &wpriv->cdev[led_type]); 165 159 if (err < 0) {