patch-2.4.19 linux-2.4.19/drivers/usb/devio.c

Next file: linux-2.4.19/drivers/usb/emi26.c
Previous file: linux-2.4.19/drivers/usb/devices.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.18/drivers/usb/devio.c linux-2.4.19/drivers/usb/devio.c
@@ -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 = {

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)