Re: [PATCH] USB and Driver Core patches for 2.6.10

Greg KH
2005-01-08T06:40:38Z

ChangeSet 1.1938.446.11, 2004/12/15 16:01:23-08:00, eolson@MIT.EDU

[PATCH] usb-serial: add tty_hangup on disconnect

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 (eolson@mit.edu)
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>

drivers/usb/serial/usb-serial.c | 7 +++++++
1 files changed, 7 insertions(+)

diff -Nru a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
--- a/drivers/usb/serial/usb-serial.c 2005-01-07 15:50:08 -08:00
+++ b/drivers/usb/serial/usb-serial.c 2005-01-07 15:50:08 -08:00
@@ -1238,13 +1238,20 @@

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);