When a USB serial device is disconnected, user applications performing a read() now receive an error code, rather than waiting indefinitely. The included patch is originally from Al Borchers, massaged to apply to 2.6.9 and 2.6.10-rc2. I've tested it on 2.6.9, but not on 2.6.10-rc2.

Al Borcher's original post: http://www.mail-archive.com/linux-usb-devel@lists.sourceforge.net/msg27475.html

Signed-off-by: Edwin Olson ([EMAIL PROTECTED])

diff -uprbB -X dontdiff linux-2.6.9-orig/drivers/usb/serial/usb-serial.c linux-2.6.9-discon/drivers/usb/serial/usb-serial.c
--- linux-2.6.9-orig/drivers/usb/serial/usb-serial.c	2004-10-18 17:55:36.000000000 -0400
+++ linux-2.6.9-discon/drivers/usb/serial/usb-serial.c	2004-11-30 21:23:16.338244909 -0500
@@ -1189,13 +1189,21 @@ probe_error:
 
 void usb_serial_disconnect(struct usb_interface *interface)
 {
+	int i;
 	struct usb_serial *serial = usb_get_intfdata (interface);
 	struct device *dev = &interface->dev;
+	struct usb_serial_port *port;
 
 	dbg ("%s", __FUNCTION__);
 
 	usb_set_intfdata (interface, NULL);
 	if (serial) {
+		for (i = 0; i < serial->num_ports; ++i) {
+			port = serial->port[i];
+			if (port && port->tty) {
+				tty_hangup(port->tty);
+			}
+		}
 		/* let the last holder of this object 
 		 * cause it to be cleaned up */
 		kref_put(&serial->kref, destroy_serial);

Reply via email to