lenovo-wmi-hotkey: Fixed a kernel error report for some Lenovo non-ThinkPad devices
PATCH v3 1/1 lenovo-wmi-hotkey: Fixed a kernel error report for some Lenovo non-ThinkPad devices
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 LED. Add a decision to judge this device support mute LED or not. Without this decision, not support both of mic mute LED and audio mute LED Lenovo non-ThinkPad brand devices (including Ideapad/Yoga/Xiaoxin/Gaming/ThinkBook, etc.) will report a failed message with error -5.
---
Changes in v3:
- Reverse orignal logic (obj && obj->type == ACPI_TYPE_INTEGER) and add new decision for led_version == 0.
- Optimize the descriptions based on reviewer comments.
Changes in v2:
- Add warning message and then return 0 if the device support mute LED abnormaly, based on Hans suggestion and Armin previous patch.
.../x86/lenovo-wmi-hotkey-utilities.c | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +18 -6
@@ -127,21 +127,30 @@ static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, structelse return -EIO ; - wpriv->cdev[led_type].max_brightness =LED_ON ; - wpriv->cdev[led_type].flags =LED_CORE_SUSPENDRESUME ; +/* +* 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 now.\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 now.\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, structreturn -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);
Signature · 1 line
2.43.0
Ilpo Järvinen
maintainerQuoted 11 lines · Jackie Dong
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 LED. Add a decision to judge this device support mute LED or not. Without this decision, not support both of mic mute LED and audio mute LED Lenovo non-ThinkPad brand devices (including Ideapad/Yoga/Xiaoxin/Gaming/ThinkBook, etc.) will report a failed message with error -5.
Signed-off-by Jackie Dong <[email protected]>Suggested-by Hans de Goede <[email protected]>Reviewed-by Ilpo Järvinen <[email protected]>
Hi Jackie,
Please don't add Reviewed-by nor Tested-by tags unless they were explicitly given to you.
Quoted 19 lines
---
Changes in v3:
- Reverse orignal logic (obj &&obj->type==ACPI_TYPE_INTEGER) and add new decision forled_version== 0.
- Optimize the descriptions based on reviewer comments.Changes in v2:
- Add warning message and then return 0 if the device support mute LED abnormaly, based on Hans suggestion and Armin previous patch..../x86/lenovo-wmi-hotkey-utilities.c | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-)drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +0
-0
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, struct · line 128
Quoted 2 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +0
-0@@ -127,21 +127,30 @@ static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, structelse return -EIO ;
The logic was not reversed as requested. Please change this code to:
union acpi_object *obj __free(kfree) = output.pointer; if (!obj || obj->type != ACPI_TYPE_INTEGER) return -EIO; led_version = obj->integer.value;
Quoted 6 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +4
-2- wpriv->cdev[led_type].max_brightness =LED_ON ; - wpriv->cdev[led_type].flags =LED_CORE_SUSPENDRESUME ; +/* +* Output parameters define: 0 means mute LED is not supported, Non-zero means +* mute LED can be supported. +*/
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, struct · line 141
Quoted 10 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +5
-2+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 now.\n" );
Drop "now" (or change it to more precise explanation why).
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, struct · line 151
Quoted 12 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +4
-2+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 now.\n" );
Ditto.
Quoted 16 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +5
-0+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, structreturn -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);
Signature · 1 line
i.
Ilpo Järvinen
maintainerIn addition, the shortlog should mention the error relates to not supported mute LEDs.
I'd also drop "some Lenovo" from to make it shorter, I think the explanation that is already in the changelog covers that (we cannot put everything to the shortlog to keep it relatively short).
Signature · 1 line
i.
Quoted 101 lines · Ilpo Järvinen
Quoted 11 lines · Jackie Dong
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 LED. Add a decision to judge this device support mute LED or not. Without this decision, not support both of mic mute LED and audio mute LED Lenovo non-ThinkPad brand devices (including Ideapad/Yoga/Xiaoxin/Gaming/ThinkBook, etc.) will report a failed message with error -5.
Signed-off-by Jackie Dong <[email protected]>Suggested-by Hans de Goede <[email protected]>Reviewed-by Ilpo Järvinen <[email protected]>Hi Jackie,
Please don't add Reviewed-by nor Tested-by tags unless they were explicitly given to you.
Quoted 19 lines
---
Changes in v3:
- Reverse orignal logic (obj &&obj->type==ACPI_TYPE_INTEGER) and add new decision forled_version== 0.
- Optimize the descriptions based on reviewer comments.Changes in v2:
- Add warning message and then return 0 if the device support mute LED abnormaly, based on Hans suggestion and Armin previous patch..../x86/lenovo-wmi-hotkey-utilities.c | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-)drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +0
-0drivers/platform/x86/lenovo-wmi-hotkey-utilities.c static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, struct · line 128
Quoted 2 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +0
-0@@ -127,21 +127,30 @@ static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, structelse return -EIO ;The logic was not reversed as requested. Please change this code to:
union acpi_object *obj __free(kfree) = output.pointer; if (!obj || obj->type != ACPI_TYPE_INTEGER) return -EIO; led_version = obj->integer.value;Quoted 6 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +4
-2- wpriv->cdev[led_type].max_brightness =LED_ON ; - wpriv->cdev[led_type].flags =LED_CORE_SUSPENDRESUME ; +/* +* Output parameters define: 0 means mute LED is not supported, Non-zero means +* mute LED can be supported. +*/ drivers/platform/x86/lenovo-wmi-hotkey-utilities.c static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, struct · line 141
Quoted 10 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +5
-2+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 now.\n" );Drop "now" (or change it to more precise explanation why).
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, struct · line 151
Quoted 12 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +4
-2+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 now.\n" );Ditto.
Quoted 16 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +5
-0+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, structreturn -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);
Re: [PATCH v3] lenovo-wmi-hotkey: Fixed a kernel error report forsome Lenovo non-ThinkPad devices
In reply to Ilpo JärvinenQuoted 10 lines · Ilpo Järvinen
Quoted 8 lines · Jackie Dong
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 LED. Add a decision to judge this device support mute LED or not. Without this decision, not support both of mic mute LED and audio mute LED Lenovo non-ThinkPad brand devices (including Ideapad/Yoga/Xiaoxin/Gaming/ThinkBook, etc.) will report a failed message with error -5.
Quoted 9 lines
Quoted 3 lines
Signed-off-by Jackie Dong <[email protected]>Suggested-by Hans de Goede <[email protected]>Reviewed-by Ilpo Järvinen <[email protected]>Hi Jackie,
Please don't add Reviewed-by nor Tested-by tags unless they were explicitly given to you.
Hi Ilpo,
I have deleted the Reviewed-by tag in next version patch.
Quoted 24 lines
Quoted 19 lines
---
Changes in v3:
- Reverse orignal logic (obj &&obj->type==ACPI_TYPE_INTEGER)and add new decision for led_version == 0.- Optimize the descriptions based on reviewer comments.
Changes in v2:
- Add warning message and then return 0 if the device support mute LED abnormaly, based on Hans suggestion and Armin previous patch..../x86/lenovo-wmi-hotkey-utilities.c | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-)drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +0
-0drivers/platform/x86/lenovo-wmi-hotkey-utilities.c static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, struct · line 128
Quoted 2 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +0
-0@@ -127,21 +127,30 @@ static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, structelse return -EIO ;The logic was not reversed as requested. Please change this code to:
Quoted 6 lines
union acpi_object *obj __free(kfree) = output.pointer; if (!obj || obj->type != ACPI_TYPE_INTEGER) return -EIO; led_version = obj->integer.value;
It's good suggestion, I'll update it.
Quoted 10 lines
Quoted 10 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +7
-2- wpriv->cdev[led_type].max_brightness =LED_ON ; - wpriv->cdev[led_type].flags =LED_CORE_SUSPENDRESUME ; +/* +* Output parameters define: 0 means mute LED is not supported, Non-zero means +* mute LED can be supported. +*/ +if (led_version ==0 ) +return 0 ; +
Quoted 9 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, struct · line 141
Quoted 6 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +2
-2switch (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 now.\n" );Drop "now" (or change it to more precise explanation why).
I have deleted the "now" in next version patch.
Quoted 15 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, struct · line 151
Quoted 12 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +4
-2+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 now.\n" );Ditto.
I have deleted the "now" in next version patch.
Quoted 9 lines
Quoted 9 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +2
-0+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, structreturn -EINVAL ; }
Quoted 8 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c static int lenovo_super_hotkey_wmi_led_init(enum mute_led_type led_type, struct · line 169
Quoted 7 lines
drivers/platform/x86/lenovo-wmi-hotkey-utilities.c +3
-0+ 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);
Thanks a lot,
Jackie