summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2011-05-18 07:40:12 +0000
committeravg <avg@FreeBSD.org>2011-05-18 07:40:12 +0000
commitfc6882fc3026eca388307b08e51e6c0ab527721d (patch)
tree833b4150a8fe2d233e2c19647530dc7996195493
parent36f936fb3cb5ac5781537dba4813fd62ccfdf458 (diff)
downloadFreeBSD-src-fc6882fc3026eca388307b08e51e6c0ab527721d.zip
FreeBSD-src-fc6882fc3026eca388307b08e51e6c0ab527721d.tar.gz
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
-rw-r--r--sys/dev/sound/usb/uaudio.c7
-rw-r--r--sys/dev/usb/input/uhid.c4
-rw-r--r--sys/dev/usb/input/ukbd.c4
-rw-r--r--sys/dev/usb/input/ums.c4
-rw-r--r--sys/dev/usb/storage/umass.c5
-rw-r--r--sys/dev/usb/storage/ustorage_fs.c6
-rw-r--r--sys/dev/usb/usb_device.c11
-rw-r--r--sys/dev/usb/usbdi.h1
8 files changed, 8 insertions, 34 deletions
diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c
index 8fbb7a6..4f8670a 100644
--- a/sys/dev/sound/usb/uaudio.c
+++ b/sys/dev/sound/usb/uaudio.c
@@ -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);
}
diff --git a/sys/dev/usb/input/uhid.c b/sys/dev/usb/input/uhid.c
index 8b33f83..a7fd899 100644
--- a/sys/dev/usb/input/uhid.c
+++ b/sys/dev/usb/input/uhid.c
@@ -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 */
diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c
index 2015233..9182663 100644
--- a/sys/dev/usb/input/ukbd.c
+++ b/sys/dev/usb/input/ukbd.c
@@ -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;
diff --git a/sys/dev/usb/input/ums.c b/sys/dev/usb/input/ums.c
index af4bfc9..af9aa1f 100644
--- a/sys/dev/usb/input/ums.c
+++ b/sys/dev/usb/input/ums.c
@@ -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;
diff --git a/sys/dev/usb/storage/umass.c b/sys/dev/usb/storage/umass.c
index de6ad9d..158d843 100644
--- a/sys/dev/usb/storage/umass.c
+++ b/sys/dev/usb/storage/umass.c
@@ -782,6 +782,7 @@ umass_probe_proto(device_t dev, struct usb_attach_arg *uaa)
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);
diff --git a/sys/dev/usb/storage/ustorage_fs.c b/sys/dev/usb/storage/ustorage_fs.c
index c62c96b..dbf025a 100644
--- a/sys/dev/usb/storage/ustorage_fs.c
+++ b/sys/dev/usb/storage/ustorage_fs.c
@@ -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
diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c
index a8b79a8..893e79d 100644
--- a/sys/dev/usb/usb_device.c
+++ b/sys/dev/usb/usb_device.c
@@ -1334,7 +1334,6 @@ usb_probe_and_attach(struct usb_device *udev, uint8_t iface_index)
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 *udev, uint8_t iface_index)
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 */
}
diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h
index 9bd326e..8f6da7c 100644
--- a/sys/dev/usb/usbdi.h
+++ b/sys/dev/usb/usbdi.h
@@ -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
OpenPOWER on IntegriCloud