Skip to content

Commit 079c953

Browse files
Alan Coxgregkh
authored andcommitted
vt:tackle kbd_table
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>
1 parent 0fb8379 commit 079c953

10 files changed

Lines changed: 660 additions & 377 deletions

File tree

‎drivers/accessibility/braille/braille_console.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,16 +244,13 @@ static int keyboard_notifier_call(struct notifier_block *blk,
244244

245245
switch (val) {
246246
case KVAL(K_CAPS):
247-
on_off = vc_kbd_led(kbd_table + fg_console,
248-
VC_CAPSLOCK);
247+
on_off = vt_get_leds(fg_console, VC_CAPSLOCK);
249248
break;
250249
case KVAL(K_NUM):
251-
on_off = vc_kbd_led(kbd_table + fg_console,
252-
VC_NUMLOCK);
250+
on_off = vt_get_leds(fg_console, VC_NUMLOCK);
253251
break;
254252
case KVAL(K_HOLD):
255-
on_off = vc_kbd_led(kbd_table + fg_console,
256-
VC_SCROLLOCK);
253+
on_off = vt_get_leds(fg_console, VC_SCROLLOCK);
257254
break;
258255
}
259256
if (on_off == 1)

‎drivers/staging/speakup/main.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,15 +1731,15 @@ static void do_handle_spec(struct vc_data *vc, u_char value, char up_flag)
17311731
switch (value) {
17321732
case KVAL(K_CAPS):
17331733
label = msg_get(MSG_KEYNAME_CAPSLOCK);
1734-
on_off = (vc_kbd_led(kbd_table + vc->vc_num, VC_CAPSLOCK));
1734+
on_off = vt_get_leds(fg_console, VC_CAPSLOCK);
17351735
break;
17361736
case KVAL(K_NUM):
17371737
label = msg_get(MSG_KEYNAME_NUMLOCK);
1738-
on_off = (vc_kbd_led(kbd_table + vc->vc_num, VC_NUMLOCK));
1738+
on_off = vt_get_leds(fg_console, VC_NUMLOCK);
17391739
break;
17401740
case KVAL(K_HOLD):
17411741
label = msg_get(MSG_KEYNAME_SCROLLLOCK);
1742-
on_off = (vc_kbd_led(kbd_table + vc->vc_num, VC_SCROLLOCK));
1742+
on_off = vt_get_leds(fg_console, VC_SCROLLOCK);
17431743
if (speakup_console[vc->vc_num])
17441744
speakup_console[vc->vc_num]->tty_stopped = on_off;
17451745
break;
@@ -2020,7 +2020,7 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym,
20202020
if (type >= 0xf0)
20212021
type -= 0xf0;
20222022
if (type == KT_PAD
2023-
&& (vc_kbd_led(kbd_table + fg_console, VC_NUMLOCK))) {
2023+
&& (vt_get_leds(fg_console, VC_NUMLOCK))) {
20242024
if (up_flag) {
20252025
spk_keydown = 0;
20262026
goto out;

‎drivers/tty/sysrq.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,9 @@ static struct sysrq_key_op sysrq_SAK_op = {
110110
#ifdef CONFIG_VT
111111
static void sysrq_handle_unraw(int key)
112112
{
113-
struct kbd_struct *kbd = &kbd_table[fg_console];
114-
115-
if (kbd)
116-
kbd->kbdmode = default_utf8 ? VC_UNICODE : VC_XLATE;
113+
vt_reset_unicode(fg_console);
117114
}
115+
118116
static struct sysrq_key_op sysrq_unraw_op = {
119117
.handler = sysrq_handle_unraw,
120118
.help_msg = "unRaw",

0 commit comments

Comments
 (0)