Skip to content

Commit

Permalink
vt:tackle kbd_table
Browse files Browse the repository at this point in the history
Keyboard struct lifetime is easy, but the locking is not and is completely
ignored by the existing code. Tackle this one head on

- Make the kbd_table private so we can run down all direct users
- Hoick the relevant ioctl handlers into the keyboard layer
- Lock them with the keyboard lock so they don't change mid keypress
- Add helpers for things like console stop/start so we isolate the poking
  around properly
- Tweak the braille console so it still builds

There are a couple of FIXME locking cases left for ioctls that are so hideous
they should be addressed in a later patch. After this patch the kbd_table is
private and all the keyboard jiggery pokery is in one place.

This update fixes speakup and also a memory leak in the original.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Alan Cox authored and gregkh committed Mar 8, 2012
1 parent 0fb8379 commit 079c953
Show file tree
Hide file tree
Showing 10 changed files with 660 additions and 377 deletions.
9 changes: 3 additions & 6 deletions drivers/accessibility/braille/braille_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,13 @@ static int keyboard_notifier_call(struct notifier_block *blk,

switch (val) {
case KVAL(K_CAPS):
on_off = vc_kbd_led(kbd_table + fg_console,
VC_CAPSLOCK);
on_off = vt_get_leds(fg_console, VC_CAPSLOCK);
break;
case KVAL(K_NUM):
on_off = vc_kbd_led(kbd_table + fg_console,
VC_NUMLOCK);
on_off = vt_get_leds(fg_console, VC_NUMLOCK);
break;
case KVAL(K_HOLD):
on_off = vc_kbd_led(kbd_table + fg_console,
VC_SCROLLOCK);
on_off = vt_get_leds(fg_console, VC_SCROLLOCK);
break;
}
if (on_off == 1)
Expand Down
8 changes: 4 additions & 4 deletions drivers/staging/speakup/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1731,15 +1731,15 @@ static void do_handle_spec(struct vc_data *vc, u_char value, char up_flag)
switch (value) {
case KVAL(K_CAPS):
label = msg_get(MSG_KEYNAME_CAPSLOCK);
on_off = (vc_kbd_led(kbd_table + vc->vc_num, VC_CAPSLOCK));
on_off = vt_get_leds(fg_console, VC_CAPSLOCK);
break;
case KVAL(K_NUM):
label = msg_get(MSG_KEYNAME_NUMLOCK);
on_off = (vc_kbd_led(kbd_table + vc->vc_num, VC_NUMLOCK));
on_off = vt_get_leds(fg_console, VC_NUMLOCK);
break;
case KVAL(K_HOLD):
label = msg_get(MSG_KEYNAME_SCROLLLOCK);
on_off = (vc_kbd_led(kbd_table + vc->vc_num, VC_SCROLLOCK));
on_off = vt_get_leds(fg_console, VC_SCROLLOCK);
if (speakup_console[vc->vc_num])
speakup_console[vc->vc_num]->tty_stopped = on_off;
break;
Expand Down Expand Up @@ -2020,7 +2020,7 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym,
if (type >= 0xf0)
type -= 0xf0;
if (type == KT_PAD
&& (vc_kbd_led(kbd_table + fg_console, VC_NUMLOCK))) {
&& (vt_get_leds(fg_console, VC_NUMLOCK))) {
if (up_flag) {
spk_keydown = 0;
goto out;
Expand Down
6 changes: 2 additions & 4 deletions drivers/tty/sysrq.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,9 @@ static struct sysrq_key_op sysrq_SAK_op = {
#ifdef CONFIG_VT
static void sysrq_handle_unraw(int key)
{
struct kbd_struct *kbd = &kbd_table[fg_console];

if (kbd)
kbd->kbdmode = default_utf8 ? VC_UNICODE : VC_XLATE;
vt_reset_unicode(fg_console);
}

static struct sysrq_key_op sysrq_unraw_op = {
.handler = sysrq_handle_unraw,
.help_msg = "unRaw",
Expand Down
Loading

0 comments on commit 079c953

Please sign in to comment.