aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorAndrew Thompson <thompsa@FreeBSD.org>2009-04-05 18:19:30 +0000
committerAndrew Thompson <thompsa@FreeBSD.org>2009-04-05 18:19:30 +0000
commitdab47558c8c53f8cf1b3bef37148e7d05b52edf1 (patch)
treec83c291bfe88d052607ac60171b8dc89cff444d1 /sys
parent7efaaa9a91de291dbc124bc88d9f99219c260dc9 (diff)
downloadsrc-dab47558c8c53f8cf1b3bef37148e7d05b52edf1.tar.gz
src-dab47558c8c53f8cf1b3bef37148e7d05b52edf1.zip
MFp4 //depot/projects/usb@159863
Speed up the endpoint descriptor search Submitted by: Hans Petter Selasky
Notes
Notes: svn path=/head/; revision=190728
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/usb/bluetooth/ng_ubt.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/sys/dev/usb/bluetooth/ng_ubt.c b/sys/dev/usb/bluetooth/ng_ubt.c
index 5e945785de17..149e1cf120de 100644
--- a/sys/dev/usb/bluetooth/ng_ubt.c
+++ b/sys/dev/usb/bluetooth/ng_ubt.c
@@ -426,6 +426,7 @@ ubt_attach(device_t dev)
struct usb2_attach_arg *uaa = device_get_ivars(dev);
struct ubt_softc *sc = device_get_softc(dev);
struct usb2_endpoint_descriptor *ed;
+ struct usb2_interface_descriptor *id;
uint16_t wMaxPacketSize;
uint8_t alt_index, i, j;
uint8_t iface_index[2] = { 0, 1 };
@@ -496,31 +497,34 @@ ubt_attach(device_t dev)
alt_index = 0;
i = 0;
j = 0;
+ ed = NULL;
- /* Search through all the descriptors looking for bidir mode */
- while (1) {
- uint16_t temp;
-
- ed = usb2_find_edesc(usb2_get_config_descriptor(uaa->device),
- 1, i, j);
- if (ed == NULL) {
- if (j != 0) {
- /* next interface */
- j = 0;
- i ++;
- continue;
- }
-
- break; /* end of interfaces */
+ /*
+ * Search through all the descriptors looking for the largest
+ * packet size:
+ */
+ while ((ed = (struct usb2_endpoint_descriptor *)usb2_desc_foreach(
+ usb2_get_config_descriptor(uaa->device),
+ (struct usb2_descriptor *)ed))) {
+
+ if ((ed->bDescriptorType == UDESC_INTERFACE) &&
+ (ed->bLength >= sizeof(*id))) {
+ id = (struct usb2_interface_descriptor *)ed;
+ i = id->bInterfaceNumber;
+ j = id->bAlternateSetting;
}
- temp = UGETW(ed->wMaxPacketSize);
- if (temp > wMaxPacketSize) {
- wMaxPacketSize = temp;
- alt_index = i;
- }
+ if ((ed->bDescriptorType == UDESC_ENDPOINT) &&
+ (ed->bLength >= sizeof(*ed)) &&
+ (i == 1)) {
+ uint16_t temp;
- j ++;
+ temp = UGETW(ed->wMaxPacketSize);
+ if (temp > wMaxPacketSize) {
+ wMaxPacketSize = temp;
+ alt_index = j;
+ }
+ }
}
/* Set alt configuration on interface #1 only if we found it */