patch-2.4.0-test10 linux/drivers/char/pc_keyb.c

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

diff -u --recursive --new-file v2.4.0-test9/linux/drivers/char/pc_keyb.c linux/drivers/char/pc_keyb.c
@@ -65,13 +65,13 @@
 static void __aux_write_ack(int val);
 #endif
 
-spinlock_t kbd_controller_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t kbd_controller_lock = SPIN_LOCK_UNLOCKED;
 static unsigned char handle_kbd_event(void);
 
 /* used only by send_data - set by keyboard_interrupt */
-static volatile unsigned char reply_expected = 0;
-static volatile unsigned char acknowledge = 0;
-static volatile unsigned char resend = 0;
+static volatile unsigned char reply_expected;
+static volatile unsigned char acknowledge;
+static volatile unsigned char resend;
 
 
 #if defined CONFIG_PSMOUSE
@@ -84,9 +84,9 @@
 #define AUX_RECONNECT 170 /* scancode when ps2 device is plugged (back) in */
  
 static struct aux_queue *queue;	/* Mouse data buffer. */
-static int aux_count = 0;
+static int aux_count;
 /* used when we send commands to the mouse that expect an ACK. */
-static unsigned char mouse_reply_expected = 0;
+static unsigned char mouse_reply_expected;
 
 #define AUX_INTS_OFF (KBD_MODE_KCC | KBD_MODE_DISABLE_MOUSE | KBD_MODE_SYS | KBD_MODE_KBD_INT)
 #define AUX_INTS_ON  (KBD_MODE_KCC | KBD_MODE_SYS | KBD_MODE_MOUSE_INT | KBD_MODE_KBD_INT)
@@ -291,7 +291,7 @@
 int pckbd_translate(unsigned char scancode, unsigned char *keycode,
 		    char raw_mode)
 {
-	static int prev_scancode = 0;
+	static int prev_scancode;
 
 	/* special prefix scancodes.. */
 	if (scancode == 0xe0 || scancode == 0xe1) {
@@ -448,7 +448,7 @@
 	unsigned char status = kbd_read_status();
 	unsigned int work = 10000;
 
-	while (status & KBD_STAT_OBF) {
+	while ((--work > 0) && (status & KBD_STAT_OBF)) {
 		unsigned char scancode;
 
 		scancode = kbd_read_input();
@@ -467,13 +467,10 @@
 		}
 
 		status = kbd_read_status();
-		
-		if (!--work) {
-			printk(KERN_ERR "pc_keyb: controller jammed (0x%02X).\n",
-				status);
-			break;
-		}
 	}
+		
+	if (!work)
+		printk(KERN_ERR "pc_keyb: controller jammed (0x%02X).\n", status);
 
 	return status;
 }
@@ -481,14 +478,13 @@
 
 static void keyboard_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	unsigned long flags;
-
 #ifdef CONFIG_VT
 	kbd_pt_regs = regs;
 #endif
-	spin_lock_irqsave(&kbd_controller_lock, flags);
+
+	spin_lock_irq(&kbd_controller_lock);
 	handle_kbd_event();
-	spin_unlock_irqrestore(&kbd_controller_lock, flags);
+	spin_unlock_irq(&kbd_controller_lock);
 }
 
 /*

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