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>
This commit is contained in:
Jackie Dong 2025-07-09 11:57:16 +08:00 committed by Ilpo Järvinen
parent e10981075a
commit c86f7bb92f
No known key found for this signature in database
GPG key ID: 59AC4F6153E5CE31

View 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);