patch-1.3.81 linux/drivers/char/keyboard.c

Next file: linux/drivers/char/mem.c
Previous file: linux/drivers/char/busmouse.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.80/linux/drivers/char/keyboard.c linux/drivers/char/keyboard.c
@@ -343,12 +343,30 @@
 	static unsigned int prev_scancode = 0;   /* remember E0, E1 */
 	char up_flag;				 /* 0 or 0200 */
 	char raw_mode;
+	int status;
 
 	pt_regs = regs;
 	send_cmd(0xAD);		/* disable keyboard */
 	kb_wait();
-	if ((inb_p(0x64) & kbd_read_mask) != 0x01)
-		goto end_kbd_intr;
+	status = inb_p(0x64);
+	if ((status & kbd_read_mask) != 0x01) {
+	  /*
+	   * On some platforms (Alpha XL for one), the init code may leave
+	   *  an interrupt hanging, yet with status indicating no data.
+	   * After making sure that there's no data indicated and its not a
+	   *  mouse interrupt, we will read the data register to clear it.
+	   * If we don't do this, the data reg stays full and will not
+	   *  allow new data or interrupt from the keyboard. Sigh...
+	   */
+	  if (!(status & 0x21)) { /* neither ODS nor OBF */
+	    scancode = inb(0x60); /* read data anyway */
+#if 0
+	    printk("keyboard: status 0x%x  mask 0x%x  data 0x%x\n",
+		   status, kbd_read_mask, scancode);
+#endif
+	  }
+	  goto end_kbd_intr;
+	}
 	scancode = inb(0x60);
 	mark_bh(KEYBOARD_BH);
 	if (reply_expected) {

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this