patch-2.2.18 linux/drivers/char/pc_keyb.c

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

diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.17/drivers/char/pc_keyb.c linux/drivers/char/pc_keyb.c
@@ -58,6 +58,7 @@
 static void kbd_write_output_w(int data);
 #ifdef CONFIG_PSMOUSE
 static void aux_write_ack(int val);
+static int aux_reconnect = 0;
 #endif
 
 spinlock_t kbd_controller_lock = SPIN_LOCK_UNLOCKED;
@@ -399,18 +400,20 @@
 		}
 		mouse_reply_expected = 0;
 	}
-    else if(scancode == AUX_RECONNECT){
-        queue->head = queue->tail = 0;  /* Flush input queue */
-        /* ping the mouse :) */
-	kb_wait();
-	kbd_write_command(KBD_CCMD_WRITE_MOUSE);
-	kb_wait();
-	kbd_write_output(AUX_ENABLE_DEV);
-	/* we expect an ACK in response. */
-	mouse_reply_expected++;
-	kb_wait();
-        return;
-    }
+	
+	else if(scancode == AUX_RECONNECT && aux_reconnect)
+	{
+	        queue->head = queue->tail = 0;  /* Flush input queue */
+        	/* ping the mouse :) */
+		kb_wait();
+		kbd_write_command(KBD_CCMD_WRITE_MOUSE);
+		kb_wait();
+		kbd_write_output(AUX_ENABLE_DEV);
+		/* we expect an ACK in response. */
+		mouse_reply_expected++;
+		kb_wait();
+	        return;
+	}
 
 	add_mouse_randomness(scancode);
 	if (aux_count) {
@@ -428,6 +431,9 @@
 #endif
 }
 
+static unsigned char kbd_exists = 1;
+static unsigned char status_mask = 0;	/* At probe time we want all */
+
 /*
  * This reads the keyboard status port, and does the
  * appropriate action.
@@ -444,17 +450,21 @@
 		unsigned char scancode;
 
 		scancode = kbd_read_input();
-#  ifdef CHECK_RECONNECT_SCANCODE
-    printk(KERN_INFO "-=db=-: kbd_read_input() : scancode == %d\n",scancode);
-#  endif
-		if (status & KBD_STAT_MOUSE_OBF) {
-			handle_mouse_event(scancode);
-		} else {
-			if (do_acknowledge(scancode))
-				handle_scancode(scancode, !(scancode & 0x80));
-			mark_bh(KEYBOARD_BH);
+		
+		/* Check for errors. Shouldnt ever happen but it does on Compaq
+		   Presario 16[89]. */
+		   
+		if(!(status& status_mask))
+		{
+			if (status & KBD_STAT_MOUSE_OBF) {
+				handle_mouse_event(scancode);
+			} else {
+				kbd_exists = 1;
+				if (do_acknowledge(scancode))
+					handle_scancode(scancode, !(scancode & 0x80));
+				mark_bh(KEYBOARD_BH);
+			}
 		}
-
 		status = kbd_read_status();
 		
 		if(!work--)
@@ -506,7 +516,7 @@
 			mdelay(1);
 			if (!--timeout) {
 #ifdef KBD_REPORT_TIMEOUTS
-				printk(KERN_WARNING "Keyboard timeout[2]\n");
+				printk(KERN_WARNING "keyboard: Timeout - AT keyboard not present?\n");
 #endif
 				return 0;
 			}
@@ -520,8 +530,10 @@
 
 void pckbd_leds(unsigned char leds)
 {
-	if (!send_data(KBD_CMD_SET_LEDS) || !send_data(leds))
-	    send_data(KBD_CMD_ENABLE);	/* re-enable kbd if any errors */
+	if (kbd_exists && (!send_data(KBD_CMD_SET_LEDS) || !send_data(leds))) {
+		send_data(KBD_CMD_ENABLE);	/* re-enable kbd if any errors */
+		kbd_exists = 0;
+	}
 }
 
 /*
@@ -545,6 +557,7 @@
 	kbd_startup_reset = 1;
 }
 
+
 #define KBD_NO_DATA	(-1)	/* No data */
 #define KBD_BAD_DATA	(-2)	/* Parity or other error */
 
@@ -736,12 +749,18 @@
 #if defined CONFIG_PSMOUSE
 	psaux_init();
 #endif
-
+	/* Switch keyboard processing to checking error bits */
+	status_mask = KBD_STAT_GTO|KBD_STAT_PERR;
 	/* Ok, finally allocate the IRQ, and off we go.. */
 	kbd_request_irq(keyboard_interrupt);
 }
 
 #if defined CONFIG_PSMOUSE
+
+void __init aux_reconnect_setup(char *str, int *ints)
+{
+	aux_reconnect=1;
+}
 
 /*
  * Check if this is a dual port controller.

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)