Index: dmitry/drivers/input/serio/i8042.c
===================================================================
--- dmitry.orig/drivers/input/serio/i8042.c	2005-07-05 16:25:15.000000000 +0200
+++ dmitry/drivers/input/serio/i8042.c	2005-07-05 16:26:05.000000000 +0200
@@ -188,7 +188,7 @@
  * encoded in bits 8-11 of the command number.
  */
 
-static int i8042_command(unsigned char *param, int command)
+static int i8042_command_aux(unsigned char *param, int command, int *aux)
 {
 	unsigned long flags;
 	int retval = 0, i = 0;
@@ -198,6 +198,9 @@
 
 	spin_lock_irqsave(&i8042_lock, flags);
 
+	if (aux)
+		*aux = 0;
+
 	retval = i8042_wait_write();
 	if (!retval) {
 		dbg("%02x -> i8042 (command)", command & 0xff);
@@ -211,13 +214,15 @@
 			i8042_write_data(param[i]);
 		}
 
+	for (i = 0; i < ((command >> 8) & 0xf); i++)
+		param[i] = 0;
+
 	if (!retval)
 		for (i = 0; i < ((command >> 8) & 0xf); i++) {
 			if ((retval = i8042_wait_read())) break;
-			if (i8042_read_status() & I8042_STR_AUXDATA)
-				param[i] = ~i8042_read_data();
-			else
-				param[i] = i8042_read_data();
+			if (aux && (i8042_read_status() & I8042_STR_AUXDATA))
+				*aux = 1;
+			param[i] = i8042_read_data();
 			dbg("%02x <- i8042 (return)", param[i]);
 		}
 
@@ -229,6 +234,11 @@
 	return retval;
 }
 
+static int i8042_command(unsigned char *param, int command)
+{
+	return i8042_command_aux(param, command, NULL);
+}
+
 /*
  * i8042_kbd_write() sends a byte out through the keyboard interface.
  */
@@ -492,8 +502,9 @@
 
 static int i8042_set_mux_mode(unsigned int mode, unsigned char *mux_version)
 {
-
 	unsigned char param;
+	int aux;
+
 /*
  * Get rid of bytes in the queue.
  */
@@ -507,13 +518,16 @@
  */
 
 	param = 0xf0;
-	if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != 0x0f)
+	if (i8042_command_aux(&param, I8042_CMD_AUX_LOOP, &aux)
+	    || !aux || param != 0xf0)
 		return -1;
 	param = mode ? 0x56 : 0xf6;
-	if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != (mode ? 0xa9 : 0x09))
+	if (i8042_command_aux(&param, I8042_CMD_AUX_LOOP, &aux)
+	    || !aux || param != (mode ? 0x56 : 0xf6))
 		return -1;
 	param = mode ? 0xa4 : 0xa5;
-	if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param == (mode ? 0x5b : 0x5a))
+	if (i8042_command_aux(&param, I8042_CMD_AUX_LOOP, &aux)
+	    || !aux || param == (mode ? 0xa4 : 0xa5))
 		return -1;
 
 	if (mux_version)
@@ -593,8 +607,9 @@
 
 static int __init i8042_check_aux(void)
 {
-	unsigned char param;
 	static int i8042_check_aux_cookie;
+	unsigned char param;
+	int aux;
 
 /*
  * Check if AUX irq is available. If it isn't, then there is no point
@@ -619,7 +634,7 @@
  */
 
 	param = 0x5a;
-	if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != 0xa5) {
+	if (i8042_command_aux(&param, I8042_CMD_AUX_LOOP, &aux) || !aux || param != 0x5a) {
 
 /*
  * External connection test - filters out AT-soldered PS/2 i8042's