* [PATCH] platform/x86: thinkpad_acpi: Don't register keyboard_lang unnecessarily
@ 2021-01-25 20:52 Hans de Goede
2021-02-02 14:04 ` Hans de Goede
0 siblings, 1 reply; 2+ messages in thread
From: Hans de Goede @ 2021-01-25 20:52 UTC (permalink / raw)
To: Mark Gross
Cc: Hans de Goede, Andy Shevchenko, Mark Pearson,
platform-driver-x86, Nitin Joshi
All recent ThinkPad BIOS-es support the GSKL method used to query the
keyboard-layout used by the ECFW for the SHIFT + other-key key-press
emulation for special keys such as e.g. the '=', '(' and ')' keys
above the numpad on 15" models.
So just checking for the method is not a good indicator of the
model supporting getting/setting the keyboard_lang.
On models where this is not supported GSKL succeeds, but it returns
METHOD_ERR in the returned integer to indicate that this is not
supported on this model.
Add a check for METHOD_ERR and return -ENODEV if it is set to
avoid registering a non-working keyboard_lang sysfs-attr on models
where this is not supported.
Cc: Nitin Joshi <njoshi1@lenovo.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/platform/x86/thinkpad_acpi.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index df2506974106..0b268e17cb7b 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -10356,6 +10356,13 @@ static int get_keyboard_lang(int *output)
if (!acpi_evalf(gskl_handle, &kbd_lang, NULL, "dd", 0x02000000))
return -EIO;
+ /*
+ * METHOD_ERR gets returned on devices where there are no special (e.g. '=',
+ * '(' and ')') keys which use layout dependent key-press emulation.
+ */
+ if (kbd_lang & METHOD_ERR)
+ return -ENODEV;
+
*output = kbd_lang;
return 0;
--
2.29.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] platform/x86: thinkpad_acpi: Don't register keyboard_lang unnecessarily
2021-01-25 20:52 [PATCH] platform/x86: thinkpad_acpi: Don't register keyboard_lang unnecessarily Hans de Goede
@ 2021-02-02 14:04 ` Hans de Goede
0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2021-02-02 14:04 UTC (permalink / raw)
To: Mark Gross
Cc: Andy Shevchenko, Mark Pearson, platform-driver-x86, Nitin Joshi
Hi,
On 1/25/21 9:52 PM, Hans de Goede wrote:
> All recent ThinkPad BIOS-es support the GSKL method used to query the
> keyboard-layout used by the ECFW for the SHIFT + other-key key-press
> emulation for special keys such as e.g. the '=', '(' and ')' keys
> above the numpad on 15" models.
>
> So just checking for the method is not a good indicator of the
> model supporting getting/setting the keyboard_lang.
>
> On models where this is not supported GSKL succeeds, but it returns
> METHOD_ERR in the returned integer to indicate that this is not
> supported on this model.
>
> Add a check for METHOD_ERR and return -ENODEV if it is set to
> avoid registering a non-working keyboard_lang sysfs-attr on models
> where this is not supported.
>
> Cc: Nitin Joshi <njoshi1@lenovo.com>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
I've applied this patch to my review-hans branch now,
so this should show up in platform-drivers-x86/for-next soon.
Regards,
Hans
> ---
> drivers/platform/x86/thinkpad_acpi.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index df2506974106..0b268e17cb7b 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -10356,6 +10356,13 @@ static int get_keyboard_lang(int *output)
> if (!acpi_evalf(gskl_handle, &kbd_lang, NULL, "dd", 0x02000000))
> return -EIO;
>
> + /*
> + * METHOD_ERR gets returned on devices where there are no special (e.g. '=',
> + * '(' and ')') keys which use layout dependent key-press emulation.
> + */
> + if (kbd_lang & METHOD_ERR)
> + return -ENODEV;
> +
> *output = kbd_lang;
>
> return 0;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-02 18:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-25 20:52 [PATCH] platform/x86: thinkpad_acpi: Don't register keyboard_lang unnecessarily Hans de Goede
2021-02-02 14:04 ` Hans de Goede
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.