--- linux-2.6.10.orig/drivers/input/joystick/gamecon.c 2004-10-20 21:25:06.000000000 +0200 +++ linux-2.6.10-rc3/drivers/input/joystick/gamecon.c 2004-12-12 14:58:35.000000000 +0100 @@ -241,7 +241,7 @@ static void gc_multi_read_packet(struct #define GC_PSX_SELECT 0x02 /* Pin 3 */ #define GC_PSX_ID(x) ((x) >> 4) /* High nibble is device type */ -#define GC_PSX_LEN(x) ((x) & 0xf) /* Low nibble is length in words */ +#define GC_PSX_LEN(x) (((x) & 0xf) << 1) /* Low nibble is length in words */ static int gc_psx_delay = GC_PSX_DELAY; module_param_named(psx_delay, gc_psx_delay, uint, 0); @@ -259,7 +259,7 @@ static short gc_psx_ddr_btn[] = { BTN_0, * the psx pad. */ -static void gc_psx_command(struct gc *gc, int b, unsigned char data[GC_PSX_LENGTH]) +static void gc_psx_command(struct gc *gc, int b, unsigned char data[5]) { int i, j, cmd, read; for (i = 0; i < 5; i++) @@ -302,10 +302,12 @@ static void gc_psx_read_packet(struct gc for (i =0; i < 5; i++) /* Find the longest pad */ if((gc_status_bit[i] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) && - (GC_PSX_LEN(id[i]) > max_len)) + (GC_PSX_LEN(id[i]) > max_len) && + /* Too long length is a sign that no joystick is present */ + (GC_PSX_LEN(id[i]) <= GC_PSX_LENGTH)) max_len = GC_PSX_LEN(id[i]); - for (i = 0; i < max_len * 2; i++) { /* Read in all the data */ + for (i = 0; i < max_len; i++) { /* Read in all the data */ gc_psx_command(gc, 0, data2); for (j = 0; j < 5; j++) data[j][i] = data2[j];