Subject: [PATCH 4 of 6] USB serial driver not attached bug fix.
From: Greg KH <[email-masked]>
To: Marcelo Tosatti <[email-masked]>
Cc: [email-masked], [email-masked]

Hi,

Here's a patch against 2.4.18-pre4 that fixes a problem with usb-serial
drivers that download firmware to their devices, disconnect, and then
reenumerate themselves.  After they download firmware, the usb serial
core would return that the device was not claimed by it, causing an
error message to the console.  This patch fixes this problem.  The patch
was originally written by Stuart MacDonald, but simplified by me.

thanks,

greg k-h

diff -Nru a/drivers/usb/serial/usb-serial.h b/drivers/usb/serial/usb-serial.h
--- a/drivers/usb/serial/usb-serial.h	Wed Jan 16 12:10:58 2002
+++ b/drivers/usb/serial/usb-serial.h	Wed Jan 16 12:10:58 2002
@@ -132,8 +132,12 @@
 
 	struct list_head	driver_list;
 	
-	/* function call to make before accepting driver */
-	/* return 0 to continue initialization, anything else to abort */
+	/* function call to make before accepting driver
+	 * return 0 to continue initialization,
+	 * < 0 aborts startup,
+	 * > 0 does not set up anything else and is useful for devices that have
+	 * downloaded firmware, and will reset themselves shortly.
+	 */
 	int (*startup) (struct usb_serial *serial);
 	
 	void (*shutdown) (struct usb_serial *serial);
diff -Nru a/drivers/usb/serial/usbserial.c b/drivers/usb/serial/usbserial.c
--- a/drivers/usb/serial/usbserial.c	Wed Jan 16 12:11:00 2002
+++ b/drivers/usb/serial/usbserial.c	Wed Jan 16 12:11:00 2002
@@ -1203,9 +1203,11 @@
 
 	/* if this device type has a startup function, call it */
 	if (type->startup) {
-		if (type->startup (serial)) {
+		i = type->startup (serial);
+		if (i < 0)
 			goto probe_error;
-		}
+		if (i > 0)
+			return serial;
 	}
 
 	/* set up the endpoint information */