[patch]usb_serial_driver insufficient for clean disconnect handling
Oliver Neukum <[email protected]>
| Newsgroups | gmane.linux.usb.devel |
|---|---|
| Organization | Novell |
| Message-ID | <[email protected]> |
Hi, it seems to me that for several usb serial drivers it is currently impossible to cleanly handle disconnect, because usb_serial_driver lacks a needed method. As we often discussed, before a disconnect handler may return, it has to finish all IO to the device. That means that usb_kill_urb() has to be called on all URBs that might be active. The serial driver does kill all standard URBs (bulk/interrupt in/out) but it does not and indeed cannot deal with any private URBs (eg. control URBs as in mos7720/mos7840). The shutdown() method is unable to do the job because it can be delayed if additional references to the port exist. To allow killing them in time I propose this additional method for usb_serial_driver. Regards Oliver Signed-off-by: Oliver Neukum <[email protected]> ----- --- linux-2.6.21-rc3-git7/include/linux/usb/serial.h~ 2007-03-12 19:32:27.000000000 +0100 +++ linux-2.6.21-rc3-git7/include/linux/usb/serial.h 2007-03-15 13:54:37.000000000 +0100 @@ -214,6 +214,7 @@ int (*probe) (struct usb_serial *serial, const struct usb_device_id *id); int (*attach) (struct usb_serial *serial); + void (*detach) (struct usb_serial *serial); int (*calc_num_ports) (struct usb_serial *serial); void (*shutdown) (struct usb_serial *serial); --- linux-2.6.21-rc3-git7/drivers/usb/serial/usb-serial.c~ 2007-03-12 19:32:59.000000000 +0100 +++ linux-2.6.21-rc3-git7/drivers/usb/serial/usb-serial.c 2007-03-15 13:54:34.000000000 +0100 @@ -1064,6 +1064,10 @@ kill_traffic(port); } } + /* allow the subdriver to cleanly kill + * private URBs */ + if (serial->type->detach) + (serial->type->detach)(serial); /* let the last holder of this object * cause it to be cleaned up */ usb_serial_put(serial); ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel