Skip to content

Commit d3272c7

Browse files
committed
platform/x86: thinkpad_acpi: Change hotkey_reserved_mask initialization
Change the hotkey_reserved_mask initialization to hardcode the list of reserved keys. There are only a few reserved keys and the code to iterate over the keymap will be removed when moving to sparse-keymaps. Note only the 32 original hotkeys are affected by the hotkey_*_mask values: if (i < sizeof(hotkey_reserved_mask)*8) hotkey_reserved_mask |= 1 << i; The (i < sizeof(hotkey_reserved_mask)*8) condition translates to (i < 32) so this code only ever set bits in hotkey_reserved_mask for the 32 original hotkeys. Therefor this patch does not set any bits in hotkey_reserved_mask for the KEY_RESERVED mappings for the adaptive keyboard scancodes. Tested-by: Mark Pearson <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 8f02154 commit d3272c7

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

drivers/platform/x86/thinkpad_acpi.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3545,6 +3545,19 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
35453545
dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
35463546
"using keymap number %lu\n", keymap_id);
35473547

3548+
/* Keys which should be reserved on both IBM and Lenovo models */
3549+
hotkey_reserved_mask = TP_ACPI_HKEY_KBD_LIGHT_MASK |
3550+
TP_ACPI_HKEY_VOLUP_MASK |
3551+
TP_ACPI_HKEY_VOLDWN_MASK |
3552+
TP_ACPI_HKEY_MUTE_MASK;
3553+
/*
3554+
* Reserve brightness up/down unconditionally on IBM models, on Lenovo
3555+
* models these are disabled based on acpi_video_get_backlight_type().
3556+
*/
3557+
if (keymap_id == TPACPI_KEYMAP_IBM_GENERIC)
3558+
hotkey_reserved_mask |= TP_ACPI_HKEY_BRGHTUP_MASK |
3559+
TP_ACPI_HKEY_BRGHTDWN_MASK;
3560+
35483561
hotkey_keycode_map = kmemdup(&tpacpi_keymaps[keymap_id],
35493562
TPACPI_HOTKEY_MAP_SIZE, GFP_KERNEL);
35503563
if (!hotkey_keycode_map) {
@@ -3560,9 +3573,6 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
35603573
if (hotkey_keycode_map[i] != KEY_RESERVED) {
35613574
input_set_capability(tpacpi_inputdev, EV_KEY,
35623575
hotkey_keycode_map[i]);
3563-
} else {
3564-
if (i < sizeof(hotkey_reserved_mask)*8)
3565-
hotkey_reserved_mask |= 1 << i;
35663576
}
35673577
}
35683578

@@ -3587,9 +3597,8 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
35873597
/* Disable brightness up/down on Lenovo thinkpads when
35883598
* ACPI is handling them, otherwise it is plain impossible
35893599
* for userspace to do something even remotely sane */
3590-
hotkey_reserved_mask |=
3591-
(1 << TP_ACPI_HOTKEYSCAN_FNHOME)
3592-
| (1 << TP_ACPI_HOTKEYSCAN_FNEND);
3600+
hotkey_reserved_mask |= TP_ACPI_HKEY_BRGHTUP_MASK |
3601+
TP_ACPI_HKEY_BRGHTDWN_MASK;
35933602
hotkey_unmap(TP_ACPI_HOTKEYSCAN_FNHOME);
35943603
hotkey_unmap(TP_ACPI_HOTKEYSCAN_FNEND);
35953604
}

0 commit comments

Comments
 (0)