patch-2.1.131 linux/drivers/char/joystick/joy-sidewinder.c

Next file: linux/drivers/char/joystick/joy-thrustmaster.c
Previous file: linux/drivers/char/joystick/joy-logitech.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.130/linux/drivers/char/joystick/joy-sidewinder.c linux/drivers/char/joystick/joy-sidewinder.c
@@ -88,6 +88,11 @@
 	} while (delays[i++]);
 	__restore_flags(flags);
 
+	for (i = 0; i < 4; i++) {
+		udelay(300);
+		outb(0xff, io);
+	}
+
 	return;
 }
 
@@ -137,19 +142,21 @@
 	__restore_flags(flags);
 
 	*data = 0;
-	t = i;
 
-	if (t == l1) {
+	if (i == l1) {
+		t = i > 64 ? 64 : i;
 		for (i = 0; i < t; i++)
 			*data |= (__u64) (buf[i] & 1) << i;
 		return t;
 	}
-	if (t == l2) {
+	if (i == l2) {
+		t = i > 22 ? 22 : i;
 		for (i = 0; i < t; i++)
 			*data |= (__u64) buf[i] << (3 * i);
 		return t * 3;
 	}
-	return t;
+
+	return i;
 }
 
 /*
@@ -199,7 +206,7 @@
 				i = js_sw_read_packet(info->io, -1, 22, JS_SW_EXT_STROBE, &data);
 			} else {
 				i = js_sw_read_packet(info->io, 64, 66, JS_SW_EXT_STROBE, &data);
-				if (i == 192) info->optimize = 1;
+				if (i == 198) info->optimize = 1;
 			}
 
 			if (i < 60) {
@@ -456,9 +463,9 @@
 	int i;
 	struct js_sw_info *info;
 
-	while (js_sw_port) {
+	while (js_sw_port != NULL) {
 		for (i = 0; i < js_sw_port->ndevs; i++)
-			if (js_sw_port->devs[i])
+			if (js_sw_port->devs[i] != NULL)
 				js_unregister_device(js_sw_port->devs[i]);
 		info = js_sw_port->info;
 		release_region(info->io, 1);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov