|
From: James S. <jsi...@us...> - 2002-11-28 00:26:57
|
Update of /cvsroot/linuxconsole/ruby/linux/drivers/char
In directory sc8-pr-cvs1:/tmp/cvs-serv8509/linux/drivers/char
Modified Files:
decvte.c keyboard.c vt_ioctl.c
Log Message:
More global varibales nuked for the keyboard.
Index: decvte.c
===================================================================
RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/char/decvte.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- decvte.c 1 Nov 2002 23:27:32 -0000 1.22
+++ decvte.c 28 Nov 2002 00:26:54 -0000 1.23
@@ -1757,8 +1757,7 @@
case 1: /* LED 1 on */
case 2: /* LED 2 on */
case 3: /* LED 3 on */
- setledstate(&vc->kbd_table,
- (par[0] < 3) ? par[0] : 4);
+ setledstate(vc, (par[0] < 3) ? par[0] : 4);
case 4: /* LED 4 on */
;
}
Index: keyboard.c
===================================================================
RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/char/keyboard.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- keyboard.c 23 Nov 2002 00:55:50 -0000 1.80
+++ keyboard.c 28 Nov 2002 00:26:54 -0000 1.81
@@ -35,37 +35,14 @@
#include <linux/init.h>
#include <linux/slab.h>
-#include <linux/console_struct.h>
-#include <linux/kbd_kern.h>
#include <linux/kbd_diacr.h>
#include <linux/vt_kern.h>
#include <linux/sysrq.h>
#include <linux/input.h>
static void kbd_disconnect(struct input_handle *handle);
-extern void ctrl_alt_del(void);
-
-/*
- * Exported functions/variables
- */
-
-#ifndef KBD_DEFMODE
-#define KBD_DEFMODE ((1 << VC_REPEAT) | (1 << VC_META))
-#endif
-
-#ifndef KBD_DEFLEDS
-/*
- * Some laptops take the 789uiojklm,. keys as number pad when NumLock is on.
- * This seems a good reason to start with NumLock off.
- */
-#define KBD_DEFLEDS 0
-#endif
-
-#ifndef KBD_DEFLOCK
-#define KBD_DEFLOCK 0
-#endif
-
extern int do_poke_blanked_console;
+extern void ctrl_alt_del(void);
void compute_shiftstate(void);
struct pt_regs *kbd_pt_regs;
EXPORT_SYMBOL(kbd_pt_regs);
@@ -108,17 +85,11 @@
};
const int NR_TYPES = ARRAY_SIZE(max_vals);
-
-struct kbd_struct kbd_table[MAX_NR_CONSOLES];
-static struct kbd_struct *kbd = kbd_table;
-static struct kbd_struct kbd0;
-
int spawnpid, spawnsig;
/*
* Variables exported for vt.c
*/
-
int shift_state = 0;
/*
@@ -133,9 +104,6 @@
static unsigned char diacr;
static char rep; /* flag telling character repeat */
-static unsigned char ledstate = 0xff; /* undefined */
-static unsigned char ledioctl;
-
static struct ledptr {
unsigned int *addr;
unsigned int mask;
@@ -161,106 +129,78 @@
* Translation of scancodes to keycodes. We set them on only the first attached
* keyboard - for per-keyboard setting, /dev/input/event is more useful.
*/
-int getkeycode(unsigned int scancode)
+int getkeycode(struct input_handle *handle, unsigned int scancode)
{
- struct list_head * node;
- struct input_dev *dev = NULL;
-
- list_for_each(node,&kbd_handler.h_list) {
- struct input_handle * handle = to_handle_h(node);
- if (handle->dev->keycodesize) {
- dev = handle->dev;
- break;
- }
- }
+ struct input_dev *dev = handle->dev;
if (!dev)
return -ENODEV;
-
- if (scancode < 0 || scancode >= dev->keycodemax)
+
+ if (!dev->keycodesize || (scancode < 0 || scancode >= dev->keycodemax))
return -EINVAL;
return INPUT_KEYCODE(dev, scancode);
}
-int setkeycode(unsigned int scancode, unsigned int keycode)
+int setkeycode(struct input_handle *handle, unsigned int scancode, unsigned int keycode)
{
- struct list_head * node;
- struct input_dev *dev = NULL;
+ struct input_dev *dev = handle->dev;
int i, oldkey;
- list_for_each(node,&kbd_handler.h_list) {
- struct input_handle *handle = to_handle_h(node);
- if (handle->dev->keycodesize) {
- dev = handle->dev;
- break;
- }
- }
-
if (!dev)
return -ENODEV;
- if (scancode < 0 || scancode >= dev->keycodemax)
+ if (!dev->keycodesize || (scancode < 0 || scancode >= dev->keycodemax))
return -EINVAL;
oldkey = INPUT_KEYCODE(dev, scancode);
INPUT_KEYCODE(dev, scancode) = keycode;
for (i = 0; i < dev->keycodemax; i++)
- if(INPUT_KEYCODE(dev, scancode) == oldkey)
+ if (INPUT_KEYCODE(dev, scancode) == oldkey)
break;
if (i == dev->keycodemax)
clear_bit(oldkey, dev->keybit);
set_bit(keycode, dev->keybit);
-
return 0;
}
/*
* Making beeps and bells.
*/
-static void kd_nosound(unsigned long ignored)
+void kd_nosound(unsigned long private)
{
- struct list_head * node;
-
- list_for_each(node,&kbd_handler.h_list) {
- struct input_handle *handle = to_handle_h(node);
- if (test_bit(EV_SND, handle->dev->evbit)) {
- if (test_bit(SND_TONE, handle->dev->sndbit))
- input_event(handle->dev, EV_SND, SND_TONE, 0);
- if (test_bit(SND_BELL, handle->dev->sndbit))
- input_event(handle->dev, EV_SND, SND_BELL, 0);
- }
+ struct input_handle *handle = (struct input_handle *) private;
+
+ if (test_bit(EV_SND, handle->dev->evbit)) {
+ if (test_bit(SND_TONE, handle->dev->sndbit))
+ input_event(handle->dev, EV_SND, SND_TONE, 0);
+ if (test_bit(SND_BELL, handle->dev->sndbit))
+ input_event(handle->dev, EV_SND, SND_BELL, 0);
}
}
-static struct timer_list kd_mksound_timer =
- TIMER_INITIALIZER(kd_nosound, 0, 0);
-
-void kd_mksound(unsigned int hz, unsigned int ticks)
+void kd_mksound(struct input_handle *handle, unsigned int hz, unsigned int ticks)
{
- struct list_head * node;
+/*
+ struct vt_struct *vt = vt_cons;
- del_timer(&kd_mksound_timer);
+ if (vt) {
+ del_timer(&vt->beep);
- if (hz) {
- list_for_each(node,&kbd_handler.h_list) {
- struct input_handle *handle = to_handle_h(node);
+ if (hz) {
if (test_bit(EV_SND, handle->dev->evbit)) {
- if (test_bit(SND_TONE, handle->dev->sndbit)) {
+ if (test_bit(SND_TONE, handle->dev->sndbit))
input_event(handle->dev, EV_SND, SND_TONE, hz);
- break;
- }
- if (test_bit(SND_BELL, handle->dev->sndbit)) {
+ if (test_bit(SND_BELL, handle->dev->sndbit))
input_event(handle->dev, EV_SND, SND_BELL, 1);
- break;
- }
}
- }
- if (ticks)
- mod_timer(&kd_mksound_timer, jiffies + ticks);
- } else
- kd_nosound(0);
+ if (ticks)
+ mod_timer(&vt->beep, jiffies + ticks);
+ } else
+ kd_nosound((long) handle);
+ }
+*/
}
/*
@@ -273,24 +213,19 @@
return (j > 0) ? j : 1;
}
-int kbd_rate(struct kbd_repeat *rep)
+int kbd_rate(struct input_handle *handle, struct kbd_repeat *rep)
{
- struct list_head *node;
+ struct input_dev *dev = handle->dev;
unsigned int d = 0;
unsigned int p = 0;
- list_for_each(node,&kbd_handler.h_list) {
- struct input_handle *handle = to_handle_h(node);
- struct input_dev *dev = handle->dev;
-
- if (test_bit(EV_REP, dev->evbit)) {
- if (rep->delay > 0)
- dev->rep[REP_DELAY] = ms_to_jiffies(rep->delay);
- if (rep->period > 0)
- dev->rep[REP_PERIOD] = ms_to_jiffies(rep->period);
- d = dev->rep[REP_DELAY] * 1000 / HZ;
- p = dev->rep[REP_PERIOD] * 1000 / HZ;
- }
+ if (test_bit(EV_REP, dev->evbit)) {
+ if (rep->delay > 0)
+ dev->rep[REP_DELAY] = ms_to_jiffies(rep->delay);
+ if (rep->period > 0)
+ dev->rep[REP_PERIOD] = ms_to_jiffies(rep->period);
+ d = dev->rep[REP_DELAY] * 1000 / HZ;
+ p = dev->rep[REP_PERIOD] * 1000 / HZ;
}
rep->delay = d;
rep->period = p;
@@ -306,11 +241,11 @@
if (tty) {
tty_insert_flip_char(tty, ch, 0);
- con_schedule_flip(tty);
+ schedule_work(&tty->flip.work);
}
}
-static void puts_queue(struct vc_data *vc, char *cp)
+void puts_queue(struct vc_data *vc, char *cp)
{
struct tty_struct *tty = vc->vc_tty;
@@ -321,7 +256,7 @@
tty_insert_flip_char(tty, *cp, 0);
cp++;
}
- con_schedule_flip(tty);
+ schedule_work(&tty->flip.work);
}
static void applkey(struct vc_data *vc, int key, char mode)
@@ -343,7 +278,7 @@
void to_utf8(struct vc_data *vc, ushort c)
{
if (c < 0x80)
- /* 0******* */
+ /* 0******* */
put_queue(vc, c);
else if (c < 0x800) {
/* 110***** 10****** */
@@ -431,7 +366,7 @@
diacr = 0;
}
put_queue(vc, 13);
- if (vc_kbd_mode(kbd, VC_CRLF))
+ if (get_kbd_mode(vc->kbd_table, VC_CRLF))
put_queue(vc, 10);
}
@@ -439,14 +374,14 @@
{
if (rep)
return;
- chg_vc_kbd_led(kbd, VC_CAPSLOCK);
+ chg_kbd_led(vc->kbd_table, VC_CAPSLOCK);
}
static void fn_caps_on(struct vc_data *vc)
{
if (rep)
return;
- set_vc_kbd_led(kbd, VC_CAPSLOCK);
+ set_kbd_led(vc->kbd_table, VC_CAPSLOCK);
}
static void fn_show_ptregs(struct vc_data *vc)
@@ -475,7 +410,7 @@
static void fn_num(struct vc_data *vc)
{
- if (vc_kbd_mode(kbd,VC_APPLIC))
+ if (get_kbd_mode(vc->kbd_table, VC_APPLIC))
applkey(vc, 'P', 1);
else
fn_bare_num(vc);
@@ -490,39 +425,45 @@
static void fn_bare_num(struct vc_data *vc)
{
if (!rep)
- chg_vc_kbd_led(kbd, VC_NUMLOCK);
+ chg_kbd_led(vc->kbd_table, VC_NUMLOCK);
}
static void fn_lastcons(struct vc_data *vc)
{
/* switch to the last used console, ChN */
- set_console(last_console);
+ set_console(vc->display_fg->last_console);
}
static void fn_dec_console(struct vc_data *vc)
{
- int i;
+ struct vt_struct *vt = vc->display_fg;
+ int i, j = vt->fg_console->vc_num - vt->first_vc;
+ struct vc_data *tmp = NULL;
- for (i = fg_console-1; i != fg_console; i--) {
+ for (i = j-1; i != j; i--) {
if (i == -1)
- i = MAX_NR_CONSOLES-1;
- if (vc_cons_allocated(i))
+ i = MAX_NR_USER_CONSOLES-1;
+ tmp = vt->vc_cons[i];
+ if (tmp)
break;
}
- set_console(i);
+ set_console(tmp);
}
static void fn_inc_console(struct vc_data *vc)
{
- int i;
+ struct vt_struct *vt = vc->display_fg;
+ int i, j = vt->fg_console->vc_num - vt->first_vc;
+ struct vc_data *tmp = NULL;
- for (i = fg_console+1; i != fg_console; i++) {
- if (i == MAX_NR_CONSOLES)
+ for (i = j+1; i != j; i++) {
+ if (i == MAX_NR_USER_CONSOLES)
i = 0;
- if (vc_cons_allocated(i))
+ tmp = vt->vc_cons[i];
+ if (tmp)
break;
}
- set_console(i);
+ set_console(tmp);
}
static void fn_send_intr(struct vc_data *vc)
@@ -532,17 +473,17 @@
if (!tty)
return;
tty_insert_flip_char(tty, 0, TTY_BREAK);
- con_schedule_flip(tty);
+ schedule_work(&tty->flip.work);
}
static void fn_scroll_forw(struct vc_data *vc)
{
- scrollfront(0);
+ scroll_down(vc, 0);
}
static void fn_scroll_back(struct vc_data *vc)
{
- scrollback(0);
+ scroll_up(vc, 0);
}
static void fn_show_mem(struct vc_data *vc)
@@ -582,7 +523,7 @@
*/
if (tty)
do_SAK(tty);
- reset_vc(fg_console);
+ reset_vc(vc);
}
static void fn_null(struct vc_data *vc)
@@ -603,8 +544,8 @@
return;
if (value >= ARRAY_SIZE(fn_handler))
return;
- if ((kbd->kbdmode == VC_RAW ||
- kbd->kbdmode == VC_MEDIUMRAW) &&
+ if ((vc->kbd_table.kbdmode == VC_RAW ||
+ vc->kbd_table.kbdmode == VC_MEDIUMRAW) &&
value != K_SAK)
return; /* SAK is allowed even in raw mode */
fn_handler[value](vc);
@@ -655,9 +596,11 @@
static void k_cons(struct vc_data *vc, unsigned char value, char up_flag)
{
- if (up_flag)
+ struct vc_data *tmp = find_vc(value + vc->display_fg->first_vc);
+
+ if (up_flag || !tmp)
return;
- set_console(value);
+ set_console(tmp);
}
static void k_fn(struct vc_data *vc, unsigned char value, char up_flag)
@@ -677,7 +620,7 @@
if (up_flag)
return;
- applkey(vc, cur_chars[value], vc_kbd_mode(kbd, VC_CKMODE));
+ applkey(vc, cur_chars[value], get_kbd_mode(vc->kbd_table, VC_CKMODE));
}
static void k_pad(struct vc_data *vc, unsigned char value, char up_flag)
@@ -689,12 +632,12 @@
return; /* no action, if this is a key release */
/* kludge... shift forces cursor/number keys */
- if (vc_kbd_mode(kbd, VC_APPLIC) && !shift_down[KG_SHIFT]) {
+ if (get_kbd_mode(vc->kbd_table, VC_APPLIC) && !shift_down[KG_SHIFT]) {
applkey(vc, app_map[value], 1);
return;
}
- if (!vc_kbd_led(kbd, VC_NUMLOCK))
+ if (!get_kbd_led(vc->kbd_table, VC_NUMLOCK))
switch (value) {
case KVAL(K_PCOMMA):
case KVAL(K_PDOT):
@@ -728,12 +671,12 @@
k_fn(vc, KVAL(K_PGUP), 0);
return;
case KVAL(K_P5):
- applkey(vc, 'G', vc_kbd_mode(kbd, VC_APPLIC));
+ applkey(vc, 'G', get_kbd_mode(vc->kbd_table, VC_APPLIC));
return;
}
put_queue(vc, pad_chars[value]);
- if (value == KVAL(K_PENTER) && vc_kbd_mode(kbd, VC_CRLF))
+ if (value == KVAL(K_PENTER) && get_kbd_mode(vc->kbd_table, VC_CRLF))
put_queue(vc, 10);
}
@@ -750,7 +693,7 @@
if (value == KVAL(K_CAPSSHIFT)) {
value = KVAL(K_SHIFT);
if (!up_flag)
- clr_vc_kbd_led(kbd, VC_CAPSLOCK);
+ clr_kbd_led(vc->kbd_table, VC_CAPSLOCK);
}
if (up_flag) {
@@ -770,7 +713,7 @@
/* kludge */
if (up_flag && shift_state != old_state && npadch != -1) {
- if (kbd->kbdmode == VC_UNICODE)
+ if (vc->kbd_table.kbdmode == VC_UNICODE)
to_utf8(vc, npadch & 0xffff);
else
put_queue(vc, npadch & 0xff);
@@ -783,7 +726,7 @@
if (up_flag)
return;
- if (vc_kbd_mode(kbd, VC_META)) {
+ if (get_kbd_mode(vc->kbd_table, VC_META)) {
put_queue(vc, '\033');
put_queue(vc, value);
} else
@@ -816,7 +759,7 @@
{
if (up_flag || rep)
return;
- chg_vc_kbd_lock(kbd, value);
+ chg_kbd_lock(vc->kbd_table, value);
}
static void k_slock(struct vc_data *vc, unsigned char value, char up_flag)
@@ -824,11 +767,11 @@
k_shift(vc, value, up_flag);
if (up_flag || rep)
return;
- chg_vc_kbd_slock(kbd, value);
+ chg_kbd_slock(vc->kbd_table, value);
/* try to make Alt, oops, AltGr and such work */
- if (!key_maps[kbd->lockstate ^ kbd->slockstate]) {
- kbd->slockstate = 0;
- chg_vc_kbd_slock(kbd, value);
+ if (!key_maps[vc->kbd_table.lockstate ^ vc->kbd_table.slockstate]) {
+ vc->kbd_table.slockstate = 0;
+ chg_kbd_slock(vc->kbd_table, value);
}
}
@@ -837,18 +780,18 @@
* or (ii) whatever pattern of lights people want to show using KDSETLED,
* or (iii) specified bits of specified words in kernel memory.
*/
-unsigned char getledstate(void)
+unsigned char getledstate(struct vc_data *vc)
{
- return ledstate;
+ return vc->vc_ledstate;
}
-void setledstate(struct kbd_struct *kbd, unsigned int led)
+void setledstate(struct vc_data *vc, unsigned int led)
{
if (!(led & ~7)) {
- ledioctl = led;
- kbd->ledmode = LED_SHOW_IOCTL;
+ vc->vc_ledioctl = led;
+ vc->kbd_table.ledmode = LED_SHOW_IOCTL;
} else
- kbd->ledmode = LED_SHOW_FLAGS;
+ vc->kbd_table.ledmode = LED_SHOW_FLAGS;
set_leds();
}
@@ -864,18 +807,17 @@
kbd->ledmode = LED_SHOW_FLAGS;
}
-static inline unsigned char getleds(void)
+static inline unsigned char getleds(struct vc_data *vc)
{
- struct kbd_struct *kbd = kbd_table + fg_console;
unsigned char leds;
int i;
- if (kbd->ledmode == LED_SHOW_IOCTL)
- return ledioctl;
+ if (vc->kbd_table.ledmode == LED_SHOW_IOCTL)
+ return vc->vc_ledioctl;
- leds = kbd->ledflagstate;
+ leds = vc->kbd_table.ledflagstate;
- if (kbd->ledmode == LED_SHOW_MEM) {
+ if (vc->kbd_table.ledmode == LED_SHOW_MEM) {
for (i = 0; i < 3; i++)
if (ledptrs[i].valid) {
if (*ledptrs[i].addr & ledptrs[i].mask)
@@ -904,18 +846,24 @@
static void kbd_bh(unsigned long dummy)
{
struct list_head * node;
- unsigned char leds = getleds();
+ unsigned char leds;
- if (leds != ledstate) {
- list_for_each(node,&kbd_handler.h_list) {
- struct input_handle * handle = to_handle_h(node);
- input_event(handle->dev, EV_LED, LED_SCROLLL, !!(leds & 0x01));
- input_event(handle->dev, EV_LED, LED_NUML, !!(leds & 0x02));
- input_event(handle->dev, EV_LED, LED_CAPSL, !!(leds & 0x04));
+ list_for_each(node, &kbd_handler.h_list) {
+ struct input_handle *handle = to_handle_h(node);
+ struct vt_struct *vt = vt_cons;
+
+ if (vt) {
+ leds = getleds(vt->fg_console);
+
+ if (leds != vt->fg_console->vc_ledstate) {
+ input_event(handle->dev, EV_LED, LED_SCROLLL, !!(leds & 0x01));
+ input_event(handle->dev, EV_LED, LED_NUML, !!(leds & 0x02));
+ input_event(handle->dev, EV_LED, LED_CAPSL, !!(leds & 0x04));
+
+ vt->fg_console->vc_ledstate = leds;
+ }
}
}
-
- ledstate = leds;
}
DECLARE_TASKLET_DISABLED(keyboard_tasklet, kbd_bh, 0);
@@ -998,9 +946,9 @@
}
#endif
-void kbd_keycode(unsigned int keycode, int down)
+void kbd_keycode(struct vt_struct *vt, unsigned int keycode, int down)
{
- struct vc_data *vc = vc_cons[fg_console].d;
+ struct vc_data *vc = vt->fg_console;
unsigned short keysym, *key_map;
unsigned char type, raw_mode;
struct tty_struct *tty;
@@ -1016,8 +964,6 @@
tty->driver_data = vc;
}
- kbd = kbd_table + fg_console;
-
if (keycode == KEY_LEFTALT || keycode == KEY_RIGHTALT)
sysrq_alt = down;
#if defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64)
@@ -1027,7 +973,7 @@
rep = (down == 2);
- if ((raw_mode = (kbd->kbdmode == VC_RAW)))
+ if ((raw_mode = (vc->kbd_table.kbdmode == VC_RAW)))
if (emulate_raw(vc, keycode, !down << 7))
printk(KERN_WARNING "keyboard.c: can't emulate rawmode for keycode %d\n", keycode);
@@ -1048,7 +994,7 @@
}
#endif
- if (kbd->kbdmode == VC_MEDIUMRAW) {
+ if (vc->kbd_table.kbdmode == VC_MEDIUMRAW) {
/*
* This is extended medium raw mode, with keys above 127
* encoded as 0, high 7 bits, low 7 bits, with the 0 bearing
@@ -1073,7 +1019,7 @@
else
clear_bit(keycode, key_down);
- if (rep && (!vc_kbd_mode(kbd, VC_REPEAT) || (tty &&
+ if (rep && (!get_kbd_mode(vc->kbd_table, VC_REPEAT) || (tty &&
(!L_ECHO(tty) && tty->driver.chars_in_buffer(tty))))) {
/*
* Don't repeat a key if the input buffers are not empty and the
@@ -1083,12 +1029,12 @@
return;
}
- shift_final = (shift_state | kbd->slockstate) ^ kbd->lockstate;
+ shift_final = (shift_state | vc->kbd_table.slockstate) ^ vc->kbd_table.lockstate;
key_map = key_maps[shift_final];
if (!key_map) {
compute_shiftstate();
- kbd->slockstate = 0;
+ vc->kbd_table.slockstate = 0;
return;
}
@@ -1107,7 +1053,7 @@
if (type == KT_LETTER) {
type = KT_LATIN;
- if (vc_kbd_led(kbd, VC_CAPSLOCK)) {
+ if (get_kbd_led(vc->kbd_table, VC_CAPSLOCK)) {
key_map = key_maps[shift_final ^ (1 << KG_SHIFT)];
if (key_map)
keysym = key_map[keycode];
@@ -1117,18 +1063,20 @@
(*k_handler[type])(vc, keysym & 0xff, !down);
if (type != KT_SLOCK)
- kbd->slockstate = 0;
+ vc->kbd_table.slockstate = 0;
}
static void kbd_event(struct input_handle *handle, unsigned int event_type,
unsigned int keycode, int down)
{
- if (event_type != EV_KEY)
+ struct vt_struct *vt = vt_cons;
+
+ if ((event_type != EV_KEY) || !vt)
return;
- kbd_keycode(keycode, down);
+ kbd_keycode(vt, keycode, down);
tasklet_schedule(&keyboard_tasklet);
do_poke_blanked_console = 1;
- schedule_console_callback();
+ schedule_work(&vt->vt_work);
}
static char kbd_name[] = "kbd";
@@ -1143,6 +1091,7 @@
struct input_dev *dev,
struct input_device_id *id)
{
+ struct vt_struct *vt = vt_cons;
struct input_handle *handle;
int i;
@@ -1154,32 +1103,46 @@
if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL)))
return NULL;
- memset(handle, 0, sizeof(struct input_handle));
+ memset(handle, 0, sizeof(struct input_handle));
+ /*
+ * If we have more keyboards than VTs we still register the handler.
+ * It is possible someone might add a graphics card thus needing the
+ * keyboard later
+ */
handle->dev = dev;
handle->handler = handler;
handle->name = kbd_name;
-
+ if (!vt->keyboard) {
+ vt->keyboard = handle;
+ handle->private = vt;
+ vt_map_input(vt);
+ }
input_open_device(handle);
-
return handle;
}
static void kbd_disconnect(struct input_handle *handle)
{
+ struct vt_struct *vt = handle->private;
+
+ if (vt && vt->keyboard == handle) {
+ vt->keyboard = NULL;
+ handle->private = NULL;
+ }
input_close_device(handle);
kfree(handle);
}
static struct input_device_id kbd_ids[] = {
{
- .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
- .evbit = { BIT(EV_KEY) },
+ flags: INPUT_DEVICE_ID_MATCH_EVBIT,
+ evbit: { BIT(EV_KEY) },
},
{
- .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
- .evbit = { BIT(EV_SND) },
+ flags: INPUT_DEVICE_ID_MATCH_EVBIT,
+ evbit: { BIT(EV_SND) },
},
{ }, /* Terminating entry */
@@ -1188,31 +1151,17 @@
MODULE_DEVICE_TABLE(input, kbd_ids);
static struct input_handler kbd_handler = {
- .event = kbd_event,
- .connect = kbd_connect,
- .disconnect = kbd_disconnect,
- .name = "kbd",
- .id_table = kbd_ids,
+ event: kbd_event,
+ connect: kbd_connect,
+ disconnect: kbd_disconnect,
+ name: "kbd",
+ id_table: kbd_ids,
};
int __init kbd_init(void)
{
- int i;
-
- kbd0.ledflagstate = kbd0.default_ledflagstate = KBD_DEFLEDS;
- kbd0.ledmode = LED_SHOW_FLAGS;
- kbd0.lockstate = KBD_DEFLOCK;
- kbd0.slockstate = 0;
- kbd0.modeflags = KBD_DEFMODE;
- kbd0.kbdmode = VC_XLATE;
-
- for (i = 0 ; i < MAX_NR_CONSOLES ; i++)
- kbd_table[i] = kbd0;
-
input_register_handler(&kbd_handler);
-
tasklet_enable(&keyboard_tasklet);
tasklet_schedule(&keyboard_tasklet);
-
return 0;
}
Index: vt_ioctl.c
===================================================================
RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/char/vt_ioctl.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- vt_ioctl.c 1 Nov 2002 23:27:32 -0000 1.70
+++ vt_ioctl.c 28 Nov 2002 00:26:54 -0000 1.71
@@ -921,14 +921,14 @@
/* the ioctls below only set the lights, not the functions */
/* for those, see KDGKBLED and KDSKBLED above */
case KDGETLED:
- ucval = getledstate();
+ ucval = getledstate(vc);
setchar:
return put_user(ucval, (char*)arg);
case KDSETLED:
if (!perm)
return -EPERM;
- setledstate(&vc->kbd_table, arg);
+ setledstate(vc, arg);
return 0;
/*
|