Re: [PATCH] Hotplug support for several PSX controlers

From: Peter Nelson
Date: Sun Dec 12 2004 - 16:16:11 EST


Eric Piel wrote:

Since 2.6.9, several PSX controlers in the same time can be supported. However, because of a bug, if not all the PSX controlers are pluged in then nothing works. Typically, you load gamecon with options saying that you have two PSX adapter ports and then you plug and unplug has many controllers has you want. There is a bug which prevent keypress to be detected when not all the controllers connected.

As I added to the documentation "hot swapping should work (but is not recomended)." This might make it a bit more likely to work, but still "not recomended."

The problem was that when a port didn't have a controler pluged the packet length to receive was read as very big, leading to a kind of buffer overflow. This patch checks the packet length and if it is bigger than the theoritical possible it considers that there is no controller pluged on this port.

This seems like a reasonable explination when ports float if unconnected. Your patch does almost the right thing. First gc_psx_command should take a data[5] argument, that was a logic error on my part. Second, you compare the calculated length to PSX_LENGTH, which is just saying we read in bytes. It should check <= 6, which is the longest string of packets possible (buttons, buttons, right, right, left, left, see <http://www.gamesx.com/controldata/psxcont/psxcont.htm>). Changing to compare to 6 makes the patch look good to me.

It probably works on a vanilla 2.6.10-rc3 but I highly recommand to use the Vojtech's tree which contains an important fix about PSX DDR (cf http://marc.theaimsgroup.com/?l=linux-kernel&m=110118014804716&w=2).

Vojtech already accepted my almost-identical patch when I noticed this in September. See
http://marc.theaimsgroup.com/?l=linux-kernel&m=109571247127456&w=4

I've heard that Linus wants 2.6.10 ready for Christmas, this patch should definitetly helps ;-)

I'm all for both my previous patch and this one making it into 2.6.10 =)

-Peter

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/