summaryrefslogtreecommitdiff
path: root/sys/dev/usb/if_urtwn.c
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2015-06-12 15:47:32 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2015-06-12 15:47:32 +0000
commit853beea76493cb57418349f967eda21e87ea0242 (patch)
tree2a2ebeff32380702750b299edaeebfd4fb602b8d /sys/dev/usb/if_urtwn.c
parentce761e0ed307165b2c6999367df8da02a49620d8 (diff)
Only match devices with a valid configuration.
Most of the WiFi/Ethernet USB adapter only have one configuration and always use its first interface. In order to improve USB descriptors parsing start by reducing the number of places where a configuration is set. Tests & ok stsp@
Diffstat (limited to 'sys/dev/usb/if_urtwn.c')
-rw-r--r--sys/dev/usb/if_urtwn.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/sys/dev/usb/if_urtwn.c b/sys/dev/usb/if_urtwn.c
index 0fa8b8125fe..db473980fa6 100644
--- a/sys/dev/usb/if_urtwn.c
+++ b/sys/dev/usb/if_urtwn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_urtwn.c,v 1.47 2015/05/12 11:46:15 stsp Exp $ */
+/* $OpenBSD: if_urtwn.c,v 1.48 2015/06/12 15:47:31 mpi Exp $ */
/*-
* Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -273,11 +273,11 @@ urtwn_match(struct device *parent, void *match, void *aux)
{
struct usb_attach_arg *uaa = aux;
- if (uaa->iface != NULL)
+ if (uaa->iface == NULL || uaa->configno != 1)
return (UMATCH_NONE);
return ((usb_lookup(urtwn_devs, uaa->vendor, uaa->product) != NULL) ?
- UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
+ UMATCH_VENDOR_PRODUCT_CONF_IFACE : UMATCH_NONE);
}
void
@@ -290,25 +290,12 @@ urtwn_attach(struct device *parent, struct device *self, void *aux)
int i, error;
sc->sc_udev = uaa->device;
+ sc->sc_iface = uaa->iface;
usb_init_task(&sc->sc_task, urtwn_task, sc, USB_TASK_TYPE_GENERIC);
timeout_set(&sc->scan_to, urtwn_next_scan, sc);
timeout_set(&sc->calib_to, urtwn_calib_to, sc);
- if (usbd_set_config_no(sc->sc_udev, 1, 0) != 0) {
- printf("%s: could not set configuration no\n",
- sc->sc_dev.dv_xname);
- return;
- }
-
- /* Get the first interface handle. */
- error = usbd_device2interface_handle(sc->sc_udev, 0, &sc->sc_iface);
- if (error != 0) {
- printf("%s: could not get interface handle\n",
- sc->sc_dev.dv_xname);
- return;
- }
-
if (uaa->product == USB_PRODUCT_DLINK_DWA123D1 ||
uaa->product == USB_PRODUCT_DLINK_DWA125D1 ||
uaa->product == USB_PRODUCT_ELECOM_WDC150SU2M ||