Commit 950a8f82 authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

[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.
parent 17f98d55
...@@ -297,7 +297,9 @@ static void destroy_all_async(struct dev_state *ps) ...@@ -297,7 +297,9 @@ static void destroy_all_async(struct dev_state *ps)
} }
/* /*
* 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, static void *driver_probe(struct usb_device *dev, unsigned int intf,
...@@ -310,8 +312,20 @@ static void driver_disconnect(struct usb_device *dev, void *context) ...@@ -310,8 +312,20 @@ static void driver_disconnect(struct usb_device *dev, void *context)
{ {
struct dev_state *ps = (struct dev_state *)context; struct dev_state *ps = (struct dev_state *)context;
if (ps) if (!ps)
ps->ifclaimed = 0; 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 = { struct usb_driver usbdevfs_driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment