Skip to content

Commit

Permalink
platform/x86: thinkpad_acpi: Don't register keyboard_lang unnecessarily
Browse files Browse the repository at this point in the history
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>
Link: https://lore.kernel.org/r/20210125205258.135664-1-hdegoede@redhat.com
  • Loading branch information
Hans de Goede committed Feb 2, 2021
1 parent 64b0efa commit 9e9c641
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/platform/x86/thinkpad_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -10047,6 +10047,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;
Expand Down

0 comments on commit 9e9c641

Please sign in to comment.