diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-09-29 21:04:21 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-09-29 21:26:11 -0400 |
commit | 1966cb225c6f9040ca163802cbd052c393d4448f (patch) | |
tree | bc6e6536d67d8f3752afb480b412d51e65568a83 /drivers/char/sysrq.c | |
parent | 594d63632024636a962be508dfe5ee6bfd309160 (diff) |
Input: sysrq - add locking to sysrq_filter()
Similarly to the keyboard handler, we are called by different input
devices and thus need to add spinlock if we want to maintain our
state properly.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/char/sysrq.c')
-rw-r--r-- | drivers/char/sysrq.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c index ef31bb81e843..f0ad694cc2eb 100644 --- a/drivers/char/sysrq.c +++ b/drivers/char/sysrq.c | |||
@@ -566,10 +566,16 @@ static const unsigned char sysrq_xlate[KEY_MAX + 1] = | |||
566 | static bool sysrq_down; | 566 | static bool sysrq_down; |
567 | static int sysrq_alt_use; | 567 | static int sysrq_alt_use; |
568 | static int sysrq_alt; | 568 | static int sysrq_alt; |
569 | static DEFINE_SPINLOCK(sysrq_event_lock); | ||
569 | 570 | ||
570 | static bool sysrq_filter(struct input_handle *handle, unsigned int type, | 571 | static bool sysrq_filter(struct input_handle *handle, unsigned int type, |
571 | unsigned int code, int value) | 572 | unsigned int code, int value) |
572 | { | 573 | { |
574 | bool suppress; | ||
575 | |||
576 | /* We are called with interrupts disabled, just take the lock */ | ||
577 | spin_lock(&sysrq_event_lock); | ||
578 | |||
573 | if (type != EV_KEY) | 579 | if (type != EV_KEY) |
574 | goto out; | 580 | goto out; |
575 | 581 | ||
@@ -601,7 +607,10 @@ static bool sysrq_filter(struct input_handle *handle, unsigned int type, | |||
601 | } | 607 | } |
602 | 608 | ||
603 | out: | 609 | out: |
604 | return sysrq_down; | 610 | suppress = sysrq_down; |
611 | spin_unlock(&sysrq_event_lock); | ||
612 | |||
613 | return suppress; | ||
605 | } | 614 | } |
606 | 615 | ||
607 | static int sysrq_connect(struct input_handler *handler, | 616 | static int sysrq_connect(struct input_handler *handler, |
@@ -652,8 +661,8 @@ static void sysrq_disconnect(struct input_handle *handle) | |||
652 | } | 661 | } |
653 | 662 | ||
654 | /* | 663 | /* |
655 | * We are matching on KEY_LEFTALT insteard of KEY_SYSRQ because not all | 664 | * We are matching on KEY_LEFTALT instead of KEY_SYSRQ because not all |
656 | * keyboards have SysRq ikey predefined and so user may add it to keymap | 665 | * keyboards have SysRq key predefined and so user may add it to keymap |
657 | * later, but we expect all such keyboards to have left alt. | 666 | * later, but we expect all such keyboards to have left alt. |
658 | */ | 667 | */ |
659 | static const struct input_device_id sysrq_ids[] = { | 668 | static const struct input_device_id sysrq_ids[] = { |