aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/keyboard.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2009-11-30 02:40:58 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2009-11-30 02:41:15 -0500
commit21cea58e49cf59e7c77ce2a01be432458e9f99a9 (patch)
tree69c02730498e25664f0ef32e2b97aa26ba93962c /drivers/char/keyboard.c
parentdbe1420b4ba398feef035f7cd8181ec2e492228b (diff)
Input: keyboard - add locking around event handling
Keyboard input handler is multiplexing events form all keyboard-like devices in the system. Because of that per-device lock provided by input core is not enough to prevent clashes in ked_event() and we need our own lock to ensure that only one thread at a time executing kbd_event(). Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/char/keyboard.c')
-rw-r--r--drivers/char/keyboard.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 747683f055ed..ca090e57e161 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -132,6 +132,7 @@ int shift_state = 0;
132 */ 132 */
133 133
134static struct input_handler kbd_handler; 134static struct input_handler kbd_handler;
135static DEFINE_SPINLOCK(kbd_event_lock);
135static unsigned long key_down[BITS_TO_LONGS(KEY_CNT)]; /* keyboard key bitmap */ 136static unsigned long key_down[BITS_TO_LONGS(KEY_CNT)]; /* keyboard key bitmap */
136static unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */ 137static unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */
137static int dead_key_next; 138static int dead_key_next;
@@ -1296,10 +1297,16 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
1296static void kbd_event(struct input_handle *handle, unsigned int event_type, 1297static void kbd_event(struct input_handle *handle, unsigned int event_type,
1297 unsigned int event_code, int value) 1298 unsigned int event_code, int value)
1298{ 1299{
1300 /* We are called with interrupts disabled, just take the lock */
1301 spin_lock(&kbd_event_lock);
1302
1299 if (event_type == EV_MSC && event_code == MSC_RAW && HW_RAW(handle->dev)) 1303 if (event_type == EV_MSC && event_code == MSC_RAW && HW_RAW(handle->dev))
1300 kbd_rawcode(value); 1304 kbd_rawcode(value);
1301 if (event_type == EV_KEY) 1305 if (event_type == EV_KEY)
1302 kbd_keycode(event_code, value, HW_RAW(handle->dev)); 1306 kbd_keycode(event_code, value, HW_RAW(handle->dev));
1307
1308 spin_unlock(&kbd_event_lock);
1309
1303 tasklet_schedule(&keyboard_tasklet); 1310 tasklet_schedule(&keyboard_tasklet);
1304 do_poke_blanked_console = 1; 1311 do_poke_blanked_console = 1;
1305 schedule_console_callback(); 1312 schedule_console_callback();