aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorHenrique de Moraes Holschuh <hmh@hmh.eng.br>2010-08-09 22:48:20 -0400
committerMatthew Garrett <mjg@redhat.com>2010-08-16 11:54:52 -0400
commit34a656d22f5539f613b93e7a1d14b4bd53592505 (patch)
tree7b664b042426531f9f52e4f6f4442a94d35208c6 /drivers/platform
parent217f09631a420295a9688e18aa4dbad1b385e56c (diff)
thinkpad-acpi: lock down size of hotkey keymap
Use a safer coding style for the hotkey keymap. This does not fix any problems, as the current code is correct. But it might help avoid mistakes in the future. Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index b9430e887e95..b0b66fbd796c 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -1911,6 +1911,17 @@ enum { /* hot key scan codes (derived from ACPI DSDT) */
1911 TP_ACPI_HOTKEYSCAN_VOLUMEDOWN, 1911 TP_ACPI_HOTKEYSCAN_VOLUMEDOWN,
1912 TP_ACPI_HOTKEYSCAN_MUTE, 1912 TP_ACPI_HOTKEYSCAN_MUTE,
1913 TP_ACPI_HOTKEYSCAN_THINKPAD, 1913 TP_ACPI_HOTKEYSCAN_THINKPAD,
1914 TP_ACPI_HOTKEYSCAN_UNK1,
1915 TP_ACPI_HOTKEYSCAN_UNK2,
1916 TP_ACPI_HOTKEYSCAN_UNK3,
1917 TP_ACPI_HOTKEYSCAN_UNK4,
1918 TP_ACPI_HOTKEYSCAN_UNK5,
1919 TP_ACPI_HOTKEYSCAN_UNK6,
1920 TP_ACPI_HOTKEYSCAN_UNK7,
1921 TP_ACPI_HOTKEYSCAN_UNK8,
1922
1923 /* Hotkey keymap size */
1924 TPACPI_HOTKEY_MAP_LEN
1914}; 1925};
1915 1926
1916enum { /* Keys/events available through NVRAM polling */ 1927enum { /* Keys/events available through NVRAM polling */
@@ -3113,7 +3124,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
3113 * If the above is too much to ask, don't change the keymap. 3124 * If the above is too much to ask, don't change the keymap.
3114 * Ask the thinkpad-acpi maintainer to do it, instead. 3125 * Ask the thinkpad-acpi maintainer to do it, instead.
3115 */ 3126 */
3116 static u16 ibm_keycode_map[] __initdata = { 3127 static u16 ibm_keycode_map[TPACPI_HOTKEY_MAP_LEN] __initdata = {
3117 /* Scan Codes 0x00 to 0x0B: ACPI HKEY FN+F1..F12 */ 3128 /* Scan Codes 0x00 to 0x0B: ACPI HKEY FN+F1..F12 */
3118 KEY_FN_F1, KEY_FN_F2, KEY_COFFEE, KEY_SLEEP, 3129 KEY_FN_F1, KEY_FN_F2, KEY_COFFEE, KEY_SLEEP,
3119 KEY_WLAN, KEY_FN_F6, KEY_SWITCHVIDEOMODE, KEY_FN_F8, 3130 KEY_WLAN, KEY_FN_F6, KEY_SWITCHVIDEOMODE, KEY_FN_F8,
@@ -3147,7 +3158,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
3147 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, 3158 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
3148 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, 3159 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
3149 }; 3160 };
3150 static u16 lenovo_keycode_map[] __initdata = { 3161 static u16 lenovo_keycode_map[TPACPI_HOTKEY_MAP_LEN] __initdata = {
3151 /* Scan Codes 0x00 to 0x0B: ACPI HKEY FN+F1..F12 */ 3162 /* Scan Codes 0x00 to 0x0B: ACPI HKEY FN+F1..F12 */
3152 KEY_FN_F1, KEY_COFFEE, KEY_BATTERY, KEY_SLEEP, 3163 KEY_FN_F1, KEY_COFFEE, KEY_BATTERY, KEY_SLEEP,
3153 KEY_WLAN, KEY_FN_F6, KEY_SWITCHVIDEOMODE, KEY_FN_F8, 3164 KEY_WLAN, KEY_FN_F6, KEY_SWITCHVIDEOMODE, KEY_FN_F8,
@@ -3191,7 +3202,6 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
3191 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, 3202 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
3192 }; 3203 };
3193 3204
3194#define TPACPI_HOTKEY_MAP_LEN ARRAY_SIZE(ibm_keycode_map)
3195#define TPACPI_HOTKEY_MAP_SIZE sizeof(ibm_keycode_map) 3205#define TPACPI_HOTKEY_MAP_SIZE sizeof(ibm_keycode_map)
3196#define TPACPI_HOTKEY_MAP_TYPESIZE sizeof(ibm_keycode_map[0]) 3206#define TPACPI_HOTKEY_MAP_TYPESIZE sizeof(ibm_keycode_map[0])
3197 3207
@@ -3469,7 +3479,8 @@ static bool hotkey_notify_hotkey(const u32 hkey,
3469 *send_acpi_ev = true; 3479 *send_acpi_ev = true;
3470 *ignore_acpi_ev = false; 3480 *ignore_acpi_ev = false;
3471 3481
3472 if (scancode > 0 && scancode < 0x21) { 3482 /* HKEY event 0x1001 is scancode 0x00 */
3483 if (scancode > 0 && scancode <= TPACPI_HOTKEY_MAP_LEN) {
3473 scancode--; 3484 scancode--;
3474 if (!(hotkey_source_mask & (1 << scancode))) { 3485 if (!(hotkey_source_mask & (1 << scancode))) {
3475 tpacpi_input_send_key_masked(scancode); 3486 tpacpi_input_send_key_masked(scancode);