]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
platform/x86: thinkpad_acpi: guard generic hotkey case
authorChristian Kellner <christian@kellner.me>
Wed, 19 Jul 2017 04:56:57 +0000 (21:56 -0700)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 9 Aug 2017 14:37:19 +0000 (16:37 +0200)
BugLink: http://bugs.launchpad.net/bugs/1705169
Currently when dispatching hotkeys we check if the scancode is in
the range of 0 and TPACPI_HOTKEY_MAP_LEN, although the bottom 20
entries in the hotkey keymap are already adaptive keycodes.
Therefore we introduce a TP_ACPI_HOTKEYSCAN_ADAPTIVE_START and
ensure that we are in the range 0 and ADAPTIVE_START for the generic
keycode case.

Signed-off-by: Christian Kellner <ckellner@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
(cherry picked from commit 149c8c75b38be528b8648d907195f188bc8fb0fb)
Signed-off-by: Alex Hung <alex.hung@canonical.com>
Acked-by: Colin King <colin.king@canonical.com>
Acked-by: Hui Wang <Wang <hui.wang@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/platform/x86/thinkpad_acpi.c

index cacb43fb1df7fcbd5f643788fa960a4cdb6e4e36..59b704ac38622b02e20860cb39d2830183cc4fb6 100644 (file)
@@ -1923,7 +1923,9 @@ enum {    /* hot key scan codes (derived from ACPI DSDT) */
        TP_ACPI_HOTKEYSCAN_UNK7,
        TP_ACPI_HOTKEYSCAN_UNK8,
 
-       TP_ACPI_HOTKEYSCAN_MUTE2,
+       /* Adaptive keyboard keycodes */
+       TP_ACPI_HOTKEYSCAN_ADAPTIVE_START,
+       TP_ACPI_HOTKEYSCAN_MUTE2        = TP_ACPI_HOTKEYSCAN_ADAPTIVE_START,
        TP_ACPI_HOTKEYSCAN_BRIGHTNESS_ZERO,
        TP_ACPI_HOTKEYSCAN_CLIPPING_TOOL,
        TP_ACPI_HOTKEYSCAN_CLOUD,
@@ -3657,7 +3659,6 @@ static const int adaptive_keyboard_modes[] = {
 #define DFR_CHANGE_ROW                 0x101
 #define DFR_SHOW_QUICKVIEW_ROW         0x102
 #define FIRST_ADAPTIVE_KEY             0x103
-#define ADAPTIVE_KEY_OFFSET            0x020
 
 /* press Fn key a while second, it will switch to Function Mode. Then
  * release Fn key, previous mode be restored.
@@ -3748,12 +3749,13 @@ static bool adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode)
        default:
                if (scancode < FIRST_ADAPTIVE_KEY ||
                    scancode >= FIRST_ADAPTIVE_KEY + TPACPI_HOTKEY_MAP_LEN -
-                               ADAPTIVE_KEY_OFFSET) {
+                               TP_ACPI_HOTKEYSCAN_ADAPTIVE_START) {
                        pr_info("Unhandled adaptive keyboard key: 0x%x\n",
                                        scancode);
                        return false;
                }
-               keycode = hotkey_keycode_map[scancode - FIRST_ADAPTIVE_KEY + ADAPTIVE_KEY_OFFSET];
+               keycode = hotkey_keycode_map[scancode - FIRST_ADAPTIVE_KEY +
+                                            TP_ACPI_HOTKEYSCAN_ADAPTIVE_START];
                if (keycode != KEY_RESERVED) {
                        mutex_lock(&tpacpi_inputdev_send_mutex);
 
@@ -3779,7 +3781,7 @@ static bool hotkey_notify_hotkey(const u32 hkey,
        *ignore_acpi_ev = false;
 
        /* HKEY event 0x1001 is scancode 0x00 */
-       if (scancode > 0 && scancode <= TPACPI_HOTKEY_MAP_LEN) {
+       if (scancode > 0 && scancode <= TP_ACPI_HOTKEYSCAN_ADAPTIVE_START) {
                scancode--;
                if (!(hotkey_source_mask & (1 << scancode))) {
                        tpacpi_input_send_key_masked(scancode);