* [PATCH] Input: keyboard - add locking around event handling
@ 2009-11-19 7:13 Dmitry Torokhov
0 siblings, 0 replies; only message in thread
From: Dmitry Torokhov @ 2009-11-19 7:13 UTC (permalink / raw)
To: Linux Input; +Cc: LKML
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>
---
drivers/char/keyboard.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index ce2ab67..e095ff3 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -130,6 +130,7 @@ int shift_state = 0;
*/
static struct input_handler kbd_handler;
+static DEFINE_SPINLOCK(kbd_event_lock);
static unsigned long key_down[BITS_TO_LONGS(KEY_CNT)]; /* keyboard key bitmap */
static unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */
static int dead_key_next;
@@ -1304,11 +1305,16 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
static void kbd_event(struct input_handle *handle, unsigned int event_type,
unsigned int event_code, int value)
{
+ /* We are called with interrupts disabled */
+ spin_lock(&kbd_event_lock);
+
if (event_type == EV_MSC && event_code == MSC_RAW && HW_RAW(handle->dev))
kbd_rawcode(value);
if (event_type == EV_KEY)
kbd_keycode(event_code, value, HW_RAW(handle->dev));
+ spin_unlock(&kbd_event_lock);
+
tasklet_schedule(&keyboard_tasklet);
do_poke_blanked_console = 1;
schedule_console_callback();
--
Dmitry
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-11-19 7:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-19 7:13 [PATCH] Input: keyboard - add locking around event handling Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).