From owner-p4-projects@FreeBSD.ORG Thu Mar 26 19:14:25 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 396A610656EF; Thu, 26 Mar 2009 19:14:24 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D55E010656EB for ; Thu, 26 Mar 2009 19:14:23 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id C1E358FC19 for ; Thu, 26 Mar 2009 19:14:23 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n2QJENdK066160 for ; Thu, 26 Mar 2009 19:14:23 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n2QJEN7e066158 for perforce@freebsd.org; Thu, 26 Mar 2009 19:14:23 GMT (envelope-from hselasky@FreeBSD.org) Date: Thu, 26 Mar 2009 19:14:23 GMT Message-Id: <200903261914.n2QJEN7e066158@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 159863 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Mar 2009 19:14:27 -0000 http://perforce.freebsd.org/chv.cgi?CH=159863 Change 159863 by hselasky@hselasky_laptop001 on 2009/03/26 19:13:32 USB bluetooth: - speed up the endpoint descriptor search Affected files ... .. //depot/projects/usb/src/sys/dev/usb/bluetooth/ng_ubt.c#3 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/bluetooth/ng_ubt.c#3 (text+ko) ==== @@ -426,6 +426,7 @@ 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 @@ alt_index = 0; i = 0; j = 0; + ed = NULL; - /* Search through all the descriptors looking for bidir mode */ - while (1) { - uint16_t temp; + /* + * 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))) { - 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; - } + if ((ed->bDescriptorType == UDESC_INTERFACE) && + (ed->bLength >= sizeof(*id))) { + id = (struct usb2_interface_descriptor *)ed; + i = id->bInterfaceNumber; + j = id->bAlternateSetting; + } - break; /* end of interfaces */ - } + if ((ed->bDescriptorType == UDESC_ENDPOINT) && + (ed->bLength >= sizeof(*ed)) && + (i == 1)) { + uint16_t temp; - temp = UGETW(ed->wMaxPacketSize); - if (temp > wMaxPacketSize) { - wMaxPacketSize = temp; - alt_index = i; + temp = UGETW(ed->wMaxPacketSize); + if (temp > wMaxPacketSize) { + wMaxPacketSize = temp; + alt_index = j; + } } - - j ++; } /* Set alt configuration on interface #1 only if we found it */