Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 May 2011 07:40:12 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r222051 - in head/sys/dev: sound/usb usb usb/input usb/storage
Message-ID:  <201105180740.p4I7eCVx066426@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Wed May 18 07:40:12 2011
New Revision: 222051
URL: http://svn.freebsd.org/changeset/base/222051

Log:
  usb: change to one-pass probing of device drivers
  
  This brings USB bus more in line with how newbus is supposed to be used.
  Also, because of the two-pass probing the following message was produced
  by devd in default configuration when almost any USB device was
  connected:
  	Unknown USB device: vendor <> product <> bus <>
  This should be fixed now.
  
  Note that many USB device drivers pass some information from probe
  method to attach method via ivars.  For this to continue working we rely
  on the fact that the subr_bus code calls probe method of a winning driver
  again before calling its attach method in the case where multiple
  drivers claim to support a device.  This is done because device
  description is set in successful probe methods and we want to get a correct
  device description from a winning driver.  So now this logic is re-used
  for setting ivars too.
  
  Reviewed by:	hselasky
  MFC after:	1 month

Modified:
  head/sys/dev/sound/usb/uaudio.c
  head/sys/dev/usb/input/uhid.c
  head/sys/dev/usb/input/ukbd.c
  head/sys/dev/usb/input/ums.c
  head/sys/dev/usb/storage/umass.c
  head/sys/dev/usb/storage/ustorage_fs.c
  head/sys/dev/usb/usb_device.c
  head/sys/dev/usb/usbdi.h

Modified: head/sys/dev/sound/usb/uaudio.c
==============================================================================
--- head/sys/dev/sound/usb/uaudio.c	Wed May 18 07:37:02 2011	(r222050)
+++ head/sys/dev/sound/usb/uaudio.c	Wed May 18 07:40:12 2011	(r222051)
@@ -539,9 +539,6 @@ uaudio_probe(device_t dev)
 	if (uaa->usb_mode != USB_MODE_HOST)
 		return (ENXIO);
 
-	if (uaa->use_generic == 0)
-		return (ENXIO);
-
 	/* lookup non-standard device */
 
 	if (uaa->info.bInterfaceClass != UICLASS_AUDIO) {
@@ -555,7 +552,7 @@ uaudio_probe(device_t dev)
 		if (usb_test_quirk(uaa, UQ_BAD_AUDIO))
 			return (ENXIO);
 		else
-			return (0);
+			return (BUS_PROBE_GENERIC);
 	}
 
 	/* check for MIDI stream */
@@ -564,7 +561,7 @@ uaudio_probe(device_t dev)
 		if (usb_test_quirk(uaa, UQ_BAD_MIDI))
 			return (ENXIO);
 		else
-			return (0);
+			return (BUS_PROBE_GENERIC);
 	}
 	return (ENXIO);
 }

Modified: head/sys/dev/usb/input/uhid.c
==============================================================================
--- head/sys/dev/usb/input/uhid.c	Wed May 18 07:37:02 2011	(r222050)
+++ head/sys/dev/usb/input/uhid.c	Wed May 18 07:40:12 2011	(r222051)
@@ -617,10 +617,6 @@ uhid_probe(device_t dev)
 	if (uaa->usb_mode != USB_MODE_HOST) {
 		return (ENXIO);
 	}
-	if (uaa->use_generic == 0) {
-		/* give Mouse and Keyboard drivers a try first */
-		return (ENXIO);
-	}
 	if (uaa->info.bInterfaceClass != UICLASS_HID) {
 
 		/* the Xbox 360 gamepad doesn't use the HID class */

Modified: head/sys/dev/usb/input/ukbd.c
==============================================================================
--- head/sys/dev/usb/input/ukbd.c	Wed May 18 07:37:02 2011	(r222050)
+++ head/sys/dev/usb/input/ukbd.c	Wed May 18 07:40:12 2011	(r222051)
@@ -771,7 +771,7 @@ ukbd_probe(device_t dev)
 		if (usb_test_quirk(uaa, UQ_KBD_IGNORE))
 			return (ENXIO);
 		else
-			return (BUS_PROBE_GENERIC);
+			return (BUS_PROBE_DEFAULT);
 	}
 
 	error = usbd_req_get_hid_desc(uaa->device, NULL,
@@ -793,7 +793,7 @@ ukbd_probe(device_t dev)
 		if (usb_test_quirk(uaa, UQ_KBD_IGNORE))
 			error = ENXIO;
 		else
-			error = BUS_PROBE_GENERIC;
+			error = BUS_PROBE_DEFAULT;
 	} else
 		error = ENXIO;
 

Modified: head/sys/dev/usb/input/ums.c
==============================================================================
--- head/sys/dev/usb/input/ums.c	Wed May 18 07:37:02 2011	(r222050)
+++ head/sys/dev/usb/input/ums.c	Wed May 18 07:40:12 2011	(r222051)
@@ -373,7 +373,7 @@ ums_probe(device_t dev)
 
 	if ((uaa->info.bInterfaceSubClass == UISUBCLASS_BOOT) &&
 	    (uaa->info.bInterfaceProtocol == UIPROTO_MOUSE))
-		return (BUS_PROBE_GENERIC);
+		return (BUS_PROBE_DEFAULT);
 
 	error = usbd_req_get_hid_desc(uaa->device, NULL,
 	    &d_ptr, &d_len, M_TEMP, uaa->info.bIfaceIndex);
@@ -383,7 +383,7 @@ ums_probe(device_t dev)
 
 	if (hid_is_collection(d_ptr, d_len,
 	    HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_MOUSE)))
-		error = BUS_PROBE_GENERIC;
+		error = BUS_PROBE_DEFAULT;
 	else
 		error = ENXIO;
 

Modified: head/sys/dev/usb/storage/umass.c
==============================================================================
--- head/sys/dev/usb/storage/umass.c	Wed May 18 07:37:02 2011	(r222050)
+++ head/sys/dev/usb/storage/umass.c	Wed May 18 07:40:12 2011	(r222051)
@@ -782,6 +782,7 @@ umass_probe_proto(device_t dev, struct u
 	uint32_t proto = umass_get_proto(uaa->iface);
 
 	memset(&ret, 0, sizeof(ret));
+	ret.error = BUS_PROBE_GENERIC;
 
 	/* Search for protocol enforcement */
 
@@ -870,10 +871,6 @@ umass_probe(device_t dev)
 	if (uaa->usb_mode != USB_MODE_HOST) {
 		return (ENXIO);
 	}
-	if (uaa->use_generic == 0) {
-		/* give other drivers a try first */
-		return (ENXIO);
-	}
 	temp = umass_probe_proto(dev, uaa);
 
 	return (temp.error);

Modified: head/sys/dev/usb/storage/ustorage_fs.c
==============================================================================
--- head/sys/dev/usb/storage/ustorage_fs.c	Wed May 18 07:37:02 2011	(r222050)
+++ head/sys/dev/usb/storage/ustorage_fs.c	Wed May 18 07:40:12 2011	(r222051)
@@ -334,10 +334,6 @@ ustorage_fs_probe(device_t dev)
 	if (uaa->usb_mode != USB_MODE_DEVICE) {
 		return (ENXIO);
 	}
-	if (uaa->use_generic == 0) {
-		/* give other drivers a try first */
-		return (ENXIO);
-	}
 	/* Check for a standards compliant device */
 	id = usbd_get_interface_descriptor(uaa->iface);
 	if ((id == NULL) ||
@@ -346,7 +342,7 @@ ustorage_fs_probe(device_t dev)
 	    (id->bInterfaceProtocol != UIPROTO_MASS_BBB)) {
 		return (ENXIO);
 	}
-	return (0);
+	return (BUS_PROBE_GENERIC);
 }
 
 static int

Modified: head/sys/dev/usb/usb_device.c
==============================================================================
--- head/sys/dev/usb/usb_device.c	Wed May 18 07:37:02 2011	(r222050)
+++ head/sys/dev/usb/usb_device.c	Wed May 18 07:40:12 2011	(r222051)
@@ -1334,7 +1334,6 @@ usb_probe_and_attach(struct usb_device *
 		uaa.info.bIfaceIndex = i;
 		uaa.info.bIfaceNum =
 		    iface->idesc->bInterfaceNumber;
-		uaa.use_generic = 0;
 		uaa.driver_info = 0;	/* reset driver_info */
 
 		DPRINTFN(2, "iclass=%u/%u/%u iindex=%u/%u\n",
@@ -1344,16 +1343,6 @@ usb_probe_and_attach(struct usb_device *
 		    uaa.info.bIfaceIndex,
 		    uaa.info.bIfaceNum);
 
-		/* try specific interface drivers first */
-
-		if (usb_probe_and_attach_sub(udev, &uaa)) {
-			/* ignore */
-		}
-		/* try generic interface drivers last */
-
-		uaa.use_generic = 1;
-		uaa.driver_info = 0;	/* reset driver_info */
-
 		if (usb_probe_and_attach_sub(udev, &uaa)) {
 			/* ignore */
 		}

Modified: head/sys/dev/usb/usbdi.h
==============================================================================
--- head/sys/dev/usb/usbdi.h	Wed May 18 07:37:02 2011	(r222050)
+++ head/sys/dev/usb/usbdi.h	Wed May 18 07:40:12 2011	(r222051)
@@ -357,7 +357,6 @@ struct usb_attach_arg {
 	struct usb_interface *iface;	/* current interface */
 	enum usb_hc_mode usb_mode;	/* host or device mode */
 	uint8_t	port;
-	uint8_t	use_generic;		/* hint for generic drivers */
 	uint8_t dev_state;
 #define UAA_DEV_READY		0
 #define UAA_DEV_DISABLED	1



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