thinkpad_acpi: Remember adaptive kbd presence
Subsystems (2)
PATCH 1/6 thinkpad_acpi: Remember adaptive kbd presence
Rather than checking on each suspend and resume whether the laptop has an adaptive keyboard, check when the driver is initialised.
--- drivers/platform/x86/thinkpad_acpi.c | 38 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +19 -19
@@ -318,6 +318,7 @@ static struct { u32 sensors_pdrv_attrs_registered:1; u32 sensors_pdev_attrs_registered:1; u32 hotkey_poll_active:1; + u32 has_adaptive_kbd:1; } tp_features; static struct {
@@ -3226,6 +3227,13 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)if (!tp_features.hotkey)return 1 ; +/* does it have an adaptive keyboard, like +* the Lenovo Carbon X1 2014 (2nd gen) */ +if (acpi_evalf (hkey_handle, &hkeyv,"MHKV" ,"qd" )) { +if ((hkeyv >>8 ) ==2 ) + tp_features.has_adaptive_kbd = true; + } + quirks =tpacpi_check_quirks (tpacpi_hotkey_qtable,ARRAY_SIZE (tpacpi_hotkey_qtable));
@@ -3834,28 +3842,22 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)static void hotkey_suspend (void ) { -int hkeyv; -/* Do these on suspend, we get the events on early resume! */ hotkey_wakeup_reason =TP_ACPI_WAKEUP_NONE ; hotkey_autosleep_ack =0 ;/* save previous mode of adaptive keyboard of X1 Carbon */ -if (acpi_evalf (hkey_handle, &hkeyv,"MHKV" ,"qd" )) { -if ((hkeyv >>8 ) ==2 ) { -if (!acpi_evalf (hkey_handle, - &adaptive_keyboard_prev_mode, -"GTRW" ,"dd" ,0 )) { -pr_err ("Cannot read adaptive keyboard mode.\n" ); - } +if (tp_features.has_adaptive_kbd) { +if (!acpi_evalf (hkey_handle, + &adaptive_keyboard_prev_mode, +"GTRW" ,"dd" ,0 )) { +pr_err ("Cannot read adaptive keyboard mode.\n" ); } } }static void hotkey_resume (void ) { -int hkeyv; -tpacpi_disable_brightness_delay (); if (hotkey_status_set(true) < 0 ||
@@ -3870,14 +3872,12 @@ static void hotkey_resume(void)hotkey_poll_setup_safe (false);/* restore previous mode of adapive keyboard of X1 Carbon */ -if (acpi_evalf (hkey_handle, &hkeyv,"MHKV" ,"qd" )) { -if ((hkeyv >>8 ) ==2 ) { -if (!acpi_evalf (hkey_handle, -NULL , -"STRW" ,"vd" , - adaptive_keyboard_prev_mode)) { -pr_err ("Cannot set adaptive keyboard mode.\n" ); - } +if (tp_features.has_adaptive_kbd) { +if (!acpi_evalf (hkey_handle, +NULL , +"STRW" ,"vd" , + adaptive_keyboard_prev_mode)) { +pr_err ("Cannot set adaptive keyboard mode.\n" ); } } }
Signature · 1 line
2.1.0
Quoted 2 lines · Bastien Nocera
Rather than checking on each suspend and resume whether the laptop has an adaptive keyboard, check when the driver is initialised.
Reasonable.
Quoted 10 lines
Signed-off-by Bastien Nocera <[email protected]>--- drivers/platform/x86/thinkpad_acpi.c | 38 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-)drivers/platform/x86/thinkpad_acpi.c +0
-0
...
drivers/platform/x86/thinkpad_acpi.c static int __init hotkey_init(struct ibm_init_struct *iibm) · line 3231
Quoted 6 lines
drivers/platform/x86/thinkpad_acpi.c +2
-0@@ -3226,6 +3227,13 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)if (!tp_features.hotkey)return 1 ; +/* does it have an adaptive keyboard, like +* the Lenovo Carbon X1 2014 (2nd gen) */
Please follow CodingStyle here:
/*
* Sentence formatting.
* Second line.
*/
The above is a question, just state what you're doing:
/*
* Check if we have an adaptive keyboard, like on the
* Lenovo Carbon X1 2014 (2nd Gen).
*/
Quoted 49 lines
drivers/platform/x86/thinkpad_acpi.c +10
-14+if (acpi_evalf (hkey_handle, &hkeyv,"MHKV" ,"qd" )) { +if ((hkeyv >>8 ) ==2 ) + tp_features.has_adaptive_kbd = true; + } + quirks =tpacpi_check_quirks (tpacpi_hotkey_qtable,ARRAY_SIZE (tpacpi_hotkey_qtable));@@ -3834,28 +3842,22 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)static void hotkey_suspend (void ) { -int hkeyv; -/* Do these on suspend, we get the events on early resume! */ hotkey_wakeup_reason =TP_ACPI_WAKEUP_NONE ; hotkey_autosleep_ack =0 ;/* save previous mode of adaptive keyboard of X1 Carbon */ -if (acpi_evalf (hkey_handle, &hkeyv,"MHKV" ,"qd" )) { -if ((hkeyv >>8 ) ==2 ) { -if (!acpi_evalf (hkey_handle, - &adaptive_keyboard_prev_mode, -"GTRW" ,"dd" ,0 )) { -pr_err ("Cannot read adaptive keyboard mode.\n" ); - } +if (tp_features.has_adaptive_kbd) { +if (!acpi_evalf (hkey_handle, + &adaptive_keyboard_prev_mode, +"GTRW" ,"dd" ,0 )) { +pr_err ("Cannot read adaptive keyboard mode.\n" ); } } }static void hotkey_resume (void ) { -int hkeyv; -tpacpi_disable_brightness_delay (); if (hotkey_status_set(true) < 0 ||@@ -3870,14 +3872,12 @@ static void hotkey_resume(void)hotkey_poll_setup_safe (false);/* restore previous mode of adapive keyboard of X1 Carbon */ - if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) { - if ((hkeyv >> 8) == 2) { - if (!acpi_evalf(hkey_handle,
drivers/platform/x86/thinkpad_acpi.c static void hotkey_resume(void) · line 3879
Quoted 10 lines
drivers/platform/x86/thinkpad_acpi.c +5
-5- NULL, - "STRW", "vd", - adaptive_keyboard_prev_mode)) { -pr_err ("Cannot set adaptive keyboard mode.\n" ); - } +if (tp_features.has_adaptive_kbd) { +if (!acpi_evalf (hkey_handle, +NULL , +"STRW" ,"vd" , + adaptive_keyboard_prev_mode)) {
You've saved a level of indentation, please group the arguments into fewer lines, should be two instead of four.
Otherwise, looks good.
Signature · 2 lines
Darren Hart Intel Open Source Technology Center
Quoted 31 lines · Darren Hart
Quoted 2 lines · Bastien Nocera
Rather than checking on each suspend and resume whether the laptop has an adaptive keyboard, check when the driver is initialised.
Reasonable.
Quoted 10 lines
Signed-off-by Bastien Nocera <[email protected]>--- drivers/platform/x86/thinkpad_acpi.c | 38 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-)drivers/platform/x86/thinkpad_acpi.c +0
-0...
drivers/platform/x86/thinkpad_acpi.c static int __init hotkey_init(struct ibm_init_struct *iibm) · line 3231
Quoted 6 lines
drivers/platform/x86/thinkpad_acpi.c +2
-0@@ -3226,6 +3227,13 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)if (!tp_features.hotkey)return 1 ; +/* does it have an adaptive keyboard, like +* the Lenovo Carbon X1 2014 (2nd gen) */ Please follow CodingStyle here:
/*
* Sentence formatting.
* Second line.
*/
Quoted 6 lines
The above is a question, just state what you're doing:
/*
* Check if we have an adaptive keyboard, like on the
* Lenovo Carbon X1 2014 (2nd Gen).
*/
Done.
Quoted 63 lines
Quoted 49 lines
drivers/platform/x86/thinkpad_acpi.c +10
-14+if (acpi_evalf (hkey_handle, &hkeyv,"MHKV" ,"qd" )) { +if ((hkeyv >>8 ) ==2 ) + tp_features.has_adaptive_kbd = true; + } + quirks =tpacpi_check_quirks (tpacpi_hotkey_qtable,ARRAY_SIZE (tpacpi_hotkey_qtable));@@ -3834,28 +3842,22 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)static void hotkey_suspend (void ) { -int hkeyv; -/* Do these on suspend, we get the events on early resume! */ hotkey_wakeup_reason =TP_ACPI_WAKEUP_NONE ; hotkey_autosleep_ack =0 ;/* save previous mode of adaptive keyboard of X1 Carbon */ -if (acpi_evalf (hkey_handle, &hkeyv,"MHKV" ,"qd" )) { -if ((hkeyv >>8 ) ==2 ) { -if (!acpi_evalf (hkey_handle, - &adaptive_keyboard_prev_mode, -"GTRW" ,"dd" ,0 )) { -pr_err ("Cannot read adaptive keyboard mode.\n" ); - } +if (tp_features.has_adaptive_kbd) { +if (!acpi_evalf (hkey_handle, + &adaptive_keyboard_prev_mode, +"GTRW" ,"dd" ,0 )) { +pr_err ("Cannot read adaptive keyboard mode.\n" ); } } }static void hotkey_resume (void ) { -int hkeyv; -tpacpi_disable_brightness_delay (); if (hotkey_status_set(true) < 0 ||@@ -3870,14 +3872,12 @@ static void hotkey_resume(void)hotkey_poll_setup_safe (false);/* restore previous mode of adapive keyboard of X1 Carbon */ - if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) { - if ((hkeyv >> 8) == 2) { - if (!acpi_evalf(hkey_handle,drivers/platform/x86/thinkpad_acpi.c static void hotkey_resume(void) · line 3879
Quoted 10 lines
drivers/platform/x86/thinkpad_acpi.c +5
-5- NULL, - "STRW", "vd", - adaptive_keyboard_prev_mode)) { -pr_err ("Cannot set adaptive keyboard mode.\n" ); - } +if (tp_features.has_adaptive_kbd) { +if (!acpi_evalf (hkey_handle, +NULL , +"STRW" ,"vd" , + adaptive_keyboard_prev_mode)) {You've saved a level of indentation, please group the arguments into fewer lines, should be two instead of four.
Quoted 1 line
Otherwise, looks good.
Done.