svn commit: r236895 - stable/9/sys/dev/usb

Hans Petter Selasky hselasky at FreeBSD.org
Mon Jun 11 17:18:32 UTC 2012


Author: hselasky
Date: Mon Jun 11 17:18:31 2012
New Revision: 236895
URL: http://svn.freebsd.org/changeset/base/236895

Log:
  MFC r236407:
  Improve support for detaching kernel drivers on a per interface basis.

Modified:
  stable/9/sys/dev/usb/usb_device.c
  stable/9/sys/dev/usb/usb_generic.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/usb/usb_device.c
==============================================================================
--- stable/9/sys/dev/usb/usb_device.c	Mon Jun 11 17:17:28 2012	(r236894)
+++ stable/9/sys/dev/usb/usb_device.c	Mon Jun 11 17:18:31 2012	(r236895)
@@ -750,10 +750,13 @@ usb_config_parse(struct usb_device *udev
 		if (do_init) {
 			/* setup the USB interface structure */
 			iface->idesc = id;
-			/* default setting */
-			iface->parent_iface_index = USB_IFACE_INDEX_ANY;
 			/* set alternate index */
 			iface->alt_index = alt_index;
+			/* set default interface parent */
+			if (iface_index == USB_IFACE_INDEX_ANY) {
+				iface->parent_iface_index =
+				    USB_IFACE_INDEX_ANY;
+			}
 		}
 
 		DPRINTFN(5, "found idesc nendpt=%d\n", id->bNumEndpoints);
@@ -1229,10 +1232,13 @@ usbd_set_parent_iface(struct usb_device 
 {
 	struct usb_interface *iface;
 
+	if (udev == NULL) {
+		/* nothing to do */
+		return;
+	}
 	iface = usbd_get_iface(udev, iface_index);
-	if (iface) {
+	if (iface != NULL)
 		iface->parent_iface_index = parent_index;
-	}
 }
 
 static void

Modified: stable/9/sys/dev/usb/usb_generic.c
==============================================================================
--- stable/9/sys/dev/usb/usb_generic.c	Mon Jun 11 17:17:28 2012	(r236894)
+++ stable/9/sys/dev/usb/usb_generic.c	Mon Jun 11 17:18:31 2012	(r236895)
@@ -2166,7 +2166,16 @@ ugen_ioctl_post(struct usb_fifo *f, u_lo
 			break;
 		}
 
+		/*
+		 * Detach the currently attached driver.
+		 */
 		usb_detach_device(f->udev, n, 0);
+
+		/*
+		 * Set parent to self, this should keep attach away
+		 * until the next set configuration event.
+		 */
+		usbd_set_parent_iface(f->udev, n, n);
 		break;
 
 	case USB_SET_POWER_MODE:


More information about the svn-src-stable-9 mailing list