[PATCH/RFC] 2.5.42 partial fix for older pl2303

From: Barry K. Nathan (barryn@pobox.com)
Date: Sat Oct 12 2002 - 23:30:08 EST


On Sat, Oct 12, 2002 at 06:16:44PM -0700, Greg KH wrote:
[snip stuff regarding pl2303 on 2.4.20-pre]
> 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 <barryn@pobox.com>

diff -ur linux-2.5.42/drivers/usb/serial/usb-serial.c linux-2.5.42-bkn1/drivers/usb/serial/usb-serial.c
--- linux-2.5.42/drivers/usb/serial/usb-serial.c 2002-10-12 20:13:30.000000000 -0700
+++ linux-2.5.42-bkn1/drivers/usb/serial/usb-serial.c 2002-10-12 20:22:02.000000000 -0700
@@ -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];
@@ -1259,6 +1261,15 @@
                                 }
                         }
                 }
+
+ /* 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 */
 #endif
Only in linux-2.5.42-bkn1/drivers/usb/serial: usb-serial.c~
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Oct 15 2002 - 22:00:45 EST