ChangeSet 1.738.5.22, 2002/10/13 13:44:18-07:00, barryn@pobox.com [PATCH] USB: 2.5.42 partial fix for older pl2303 On Sat, Oct 12, 2002 at 06:16:44PM -0700, Greg KH wrote: > Now, would you mind taking a look at 2.5, and fixing this there too? :) Here's a half-successful attempt. With this patch, the device no longer appears twice, and it always works on the first open (at least, so I've observed up to this point). The open following a successful open usually fails (roughly speaking, it appears to play dead), and the open following a failed open usually (always?) succeeds. So, on my PL-2303, it's not perfect but it's certainly livable. This patch is based on the one I did for 2.4, and in fact, this code functions when it's plugged into 2.4.20-pre10 instead of 2.5.42. In that scenario, the opens work 100% of the time. I'd be interested in suggestions or comments regarding this patch. Anyone who has a PL-2303 working under 2.5 might want to try this patch just to make sure it doesn't kill their working setup. -Barry K. Nathan diff -Nru a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c --- a/drivers/usb/serial/usb-serial.c Sun Oct 13 17:08:56 2002 +++ b/drivers/usb/serial/usb-serial.c Sun Oct 13 17:08:56 2002 @@ -1237,16 +1237,18 @@ } #if defined(CONFIG_USB_SERIAL_PL2303) || defined(CONFIG_USB_SERIAL_PL2303_MODULE) -#if 0 +#if 1 /* BEGIN HORRIBLE HACK FOR PL2303 */ /* this is needed due to the looney way its endpoints are set up */ - if (ifnum == 1) { - if (((dev->descriptor.idVendor == PL2303_VENDOR_ID) && - (dev->descriptor.idProduct == PL2303_PRODUCT_ID)) || - ((dev->descriptor.idVendor == ATEN_VENDOR_ID) && - (dev->descriptor.idProduct == ATEN_PRODUCT_ID))) { + if (((dev->descriptor.idVendor == PL2303_VENDOR_ID) && + (dev->descriptor.idProduct == PL2303_PRODUCT_ID)) || + ((dev->descriptor.idVendor == ATEN_VENDOR_ID) && + (dev->descriptor.idProduct == ATEN_PRODUCT_ID))) { + //if (ifnum == 1) { + if (interface != &dev->actconfig->interface[0]) { /* check out the endpoints of the other interface*/ - interface = &dev->actconfig->interface[ifnum ^ 1]; + //interface = &dev->actconfig->interface[ifnum ^ 1]; + interface = &dev->actconfig->interface[0]; iface_desc = &interface->altsetting[0]; for (i = 0; i < iface_desc->bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i]; @@ -1258,6 +1260,15 @@ ++num_interrupt_in; } } + } + + /* Now make sure the PL-2303 is configured correctly. + * If not, give up now and hope this hack will work + * properly during a later invocation of usb_serial_probe + */ + if (num_bulk_in == 0 || num_bulk_out == 0) { + info("PL-2303 hack: descriptors matched but endpoints did not"); + return NULL; } } /* END HORRIBLE HACK FOR PL2303 */