Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Jun 2012 16:30:54 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r236407 - head/sys/dev/usb
Message-ID:  <201206011630.q51GUsk7030008@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Fri Jun  1 16:30:54 2012
New Revision: 236407
URL: http://svn.freebsd.org/changeset/base/236407

Log:
  Improve support for detaching kernel drivers on a per interface basis.
  
  MFC after:	1 week

Modified:
  head/sys/dev/usb/usb_device.c
  head/sys/dev/usb/usb_generic.c

Modified: head/sys/dev/usb/usb_device.c
==============================================================================
--- head/sys/dev/usb/usb_device.c	Fri Jun  1 15:52:41 2012	(r236406)
+++ head/sys/dev/usb/usb_device.c	Fri Jun  1 16:30:54 2012	(r236407)
@@ -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: head/sys/dev/usb/usb_generic.c
==============================================================================
--- head/sys/dev/usb/usb_generic.c	Fri Jun  1 15:52:41 2012	(r236406)
+++ head/sys/dev/usb/usb_generic.c	Fri Jun  1 16:30:54 2012	(r236407)
@@ -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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206011630.q51GUsk7030008>