patch-2.2.0-pre7 linux/drivers/char/pc_keyb.c
Next file: linux/drivers/char/radio-aimslab.c
Previous file: linux/drivers/char/lp_m68k.c
Back to the patch index
Back to the overall index
- Lines: 104
- Date:
Tue Jan 12 10:14:40 1999
- Orig file:
v2.2.0-pre6/linux/drivers/char/pc_keyb.c
- Orig date:
Mon Dec 28 15:00:52 1998
diff -u --recursive --new-file v2.2.0-pre6/linux/drivers/char/pc_keyb.c linux/drivers/char/pc_keyb.c
@@ -55,6 +55,7 @@
#endif
static void kbd_write(int address, int data);
+static unsigned char handle_kbd_event(void);
spinlock_t kbd_controller_lock = SPIN_LOCK_UNLOCKED;
@@ -101,16 +102,15 @@
static inline void kb_wait(void)
{
unsigned long timeout = KBC_TIMEOUT;
- unsigned char status;
do {
- status = inb_p(KBD_STATUS_REG);
- if (status & KBD_STAT_OBF) {
- if (status & KBD_STAT_MOUSE_OBF)
- inb_p(KBD_DATA_REG); /* Flush. */
- }
+ /*
+ * "handle_kbd_event()" will handle any incoming events
+ * while we wait - keypresses or mouse movement.
+ */
+ unsigned char status = handle_kbd_event();
- if (! (inb_p(KBD_STATUS_REG) & KBD_STAT_IBF))
+ if (! (status & KBD_STAT_IBF))
return;
mdelay(1);
timeout--;
@@ -256,25 +256,6 @@
e0_keys[scancode - 128];
}
-#if DISABLE_KBD_DURING_INTERRUPTS
-static inline void send_cmd(unsigned char c)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&kbd_controller_lock, flags);
- kb_wait();
- outb(c, KBD_CNTL_REG);
- spin_unlock_irqrestore(&kbd_controller_lock, flags);
-}
-
-/* #define disable_keyboard() do { send_cmd(KBD_CCMD_KBD_DISABLE); kb_wait(); } while (0) */
-#define disable_keyboard() send_cmd(KBD_CCMD_KBD_DISABLE)
-#define enable_keyboard() send_cmd(KBD_CCMD_KBD_ENABLE)
-#else
-#define disable_keyboard() /* nothing */
-#define enable_keyboard() /* nothing */
-#endif
-
static int do_acknowledge(unsigned char scancode)
{
if (reply_expected) {
@@ -419,16 +400,17 @@
return 0200;
}
-static void keyboard_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+/*
+ * This reads the keyboard status port, and does the
+ * appropriate action.
+ *
+ * It requires that we hold the keyboard controller
+ * spinlock.
+ */
+static unsigned char handle_kbd_event(void)
{
- unsigned long flags;
- unsigned char status;
-
- disable_keyboard();
- spin_lock_irqsave(&kbd_controller_lock, flags);
- kbd_pt_regs = regs;
+ unsigned char status = inb(KBD_STATUS_REG);
- status = inb(KBD_STATUS_REG);
while (status & KBD_STAT_OBF) {
unsigned char scancode;
@@ -459,8 +441,19 @@
status = inb(KBD_STATUS_REG);
}
+ return status;
+}
+
+
+static void keyboard_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ unsigned long flags;
+
+ kbd_pt_regs = regs;
+
+ spin_lock_irqsave(&kbd_controller_lock, flags);
+ handle_kbd_event();
spin_unlock_irqrestore(&kbd_controller_lock, flags);
- enable_keyboard();
}
/*
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov