Commit cbc61f11 authored by Andy Lutomirski's avatar Andy Lutomirski Committed by Darren Hart

dell-wmi: Improve unknown hotkey handling

If DMI lists a hotkey that we don't recognize, log and ignore it
instead of trying to map it to keycode 0.  I haven't seen this happen,
but it will help maintain the key map in the future and it will help
avoid sending bogus events.

This also improves the message that we log when we get an unknown key
event.
Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
Reviewed-by: default avatarPali Rohár <pali.rohar@gmail.com>
[dvhart: remove BUILD_BUG_ON per mutual agreement on list]
Signed-off-by: default avatarDarren Hart <dvhart@linux.intel.com>
parent c1e1655b
...@@ -118,6 +118,7 @@ struct dell_bios_hotkey_table { ...@@ -118,6 +118,7 @@ struct dell_bios_hotkey_table {
static const struct dell_bios_hotkey_table *dell_bios_hotkey_table; static const struct dell_bios_hotkey_table *dell_bios_hotkey_table;
/* Uninitialized entries here are KEY_RESERVED == 0. */
static const u16 bios_to_linux_keycode[256] __initconst = { static const u16 bios_to_linux_keycode[256] __initconst = {
[0] = KEY_MEDIA, [0] = KEY_MEDIA,
[1] = KEY_NEXTSONG, [1] = KEY_NEXTSONG,
...@@ -170,7 +171,8 @@ static void dell_wmi_process_key(int reported_key) ...@@ -170,7 +171,8 @@ static void dell_wmi_process_key(int reported_key)
key = sparse_keymap_entry_from_scancode(dell_wmi_input_dev, key = sparse_keymap_entry_from_scancode(dell_wmi_input_dev,
reported_key); reported_key);
if (!key) { if (!key) {
pr_info("Unknown key %x pressed\n", reported_key); pr_info("Unknown key with scancode 0x%x pressed\n",
reported_key);
return; return;
} }
...@@ -328,10 +330,24 @@ static const struct key_entry * __init dell_wmi_prepare_new_keymap(void) ...@@ -328,10 +330,24 @@ static const struct key_entry * __init dell_wmi_prepare_new_keymap(void)
for (i = 0; i < hotkey_num; i++) { for (i = 0; i < hotkey_num; i++) {
const struct dell_bios_keymap_entry *bios_entry = const struct dell_bios_keymap_entry *bios_entry =
&dell_bios_hotkey_table->keymap[i]; &dell_bios_hotkey_table->keymap[i];
u16 keycode = bios_entry->keycode < 256 ?
/* Uninitialized entries are 0 aka KEY_RESERVED. */
u16 keycode = (bios_entry->keycode <
ARRAY_SIZE(bios_to_linux_keycode)) ?
bios_to_linux_keycode[bios_entry->keycode] : bios_to_linux_keycode[bios_entry->keycode] :
KEY_RESERVED; KEY_RESERVED;
/*
* Log if we find an entry in the DMI table that we don't
* understand. If this happens, we should figure out what
* the entry means and add it to bios_to_linux_keycode.
*/
if (keycode == KEY_RESERVED) {
pr_info("firmware scancode 0x%x maps to unrecognized keycode 0x%x\n",
bios_entry->scancode, bios_entry->keycode);
continue;
}
if (keycode == KEY_KBDILLUMTOGGLE) if (keycode == KEY_KBDILLUMTOGGLE)
keymap[i].type = KE_IGNORE; keymap[i].type = KE_IGNORE;
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment