# This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.427 -> 1.428 # drivers/usb/devio.c 1.8 -> 1.9 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 02/04/18 david-b@pacbell.net 1.428 # [PATCH] USB devio device removal fix # # USB devio device removal fix # # Fixes problem with using usbfs and a device is removed while the # device still has pending events. # -------------------------------------------- # diff -Nru a/drivers/usb/devio.c b/drivers/usb/devio.c --- a/drivers/usb/devio.c Thu Apr 18 13:53:53 2002 +++ b/drivers/usb/devio.c Thu Apr 18 13:53:53 2002 @@ -286,7 +286,9 @@ } /* - * interface claiming + * interface claims are made only at the request of user level code, + * which can also release them (explicitly or by closing files). + * they're also undone when devices disconnect. */ static void *driver_probe(struct usb_device *dev, unsigned int intf, @@ -299,7 +301,20 @@ { struct dev_state *ps = (struct dev_state *)context; + if (!ps) + return; + + /* this waits till synchronous requests complete */ + down_write (&ps->devsem); + + /* prevent new I/O requests */ + ps->dev = 0; ps->ifclaimed = 0; + + /* force async requests to complete */ + destroy_all_async (ps); + + up_write (&ps->devsem); } struct usb_driver usbdevfs_driver = {