Skip to content

Commit c86f7bb

Browse files
Jackie Dongij-intel
authored andcommitted
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 <[email protected]> Suggested-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ij: major edits to the changelog.] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent e109810 commit c86f7bb

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

drivers/platform/x86/lenovo-wmi-hotkey-utilities.c

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,26 +122,35 @@ static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, struct
122122
return -EIO;
123123

124124
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)
128126
return -EIO;
129127

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+
132137

133138
switch (led_type) {
134139
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+
}
137144

138145
wpriv->cdev[led_type].name = "platform::micmute";
139146
wpriv->cdev[led_type].brightness_set_blocking = &lsh_wmi_micmute_led_set;
140147
wpriv->cdev[led_type].default_trigger = "audio-micmute";
141148
break;
142149
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+
}
145154

146155
wpriv->cdev[led_type].name = "platform::mute";
147156
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
152161
return -EINVAL;
153162
}
154163

164+
wpriv->cdev[led_type].max_brightness = LED_ON;
165+
wpriv->cdev[led_type].flags = LED_CORE_SUSPENDRESUME;
166+
155167
err = devm_led_classdev_register(dev, &wpriv->cdev[led_type]);
156168
if (err < 0) {
157169
dev_err(dev, "Could not register mute LED %d : %d\n", led_type, err);

0 commit comments

Comments
 (0)