summaryrefslogtreecommitdiff
path: root/sys/dev/usb/if_athn_usb.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_athn_usb.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_athn_usb.c')
-rw-r--r--sys/dev/usb/if_athn_usb.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/sys/dev/usb/if_athn_usb.c b/sys/dev/usb/if_athn_usb.c
index 9513cc7d0be..4f473a62e44 100644
--- a/sys/dev/usb/if_athn_usb.c
+++ b/sys/dev/usb/if_athn_usb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_athn_usb.c,v 1.33 2015/03/02 15:23:28 stsp Exp $ */
+/* $OpenBSD: if_athn_usb.c,v 1.34 2015/06/12 15:47:31 mpi Exp $ */
/*-
* Copyright (c) 2011 Damien Bergamini <damien.bergamini@free.fr>
@@ -220,11 +220,11 @@ athn_usb_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 ((athn_usb_lookup(uaa->vendor, uaa->product) != NULL) ?
- UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
+ UMATCH_VENDOR_PRODUCT_CONF_IFACE : UMATCH_NONE);
}
void
@@ -233,9 +233,9 @@ athn_usb_attach(struct device *parent, struct device *self, void *aux)
struct athn_usb_softc *usc = (struct athn_usb_softc *)self;
struct athn_softc *sc = &usc->sc_sc;
struct usb_attach_arg *uaa = aux;
- int error;
usc->sc_udev = uaa->device;
+ usc->sc_iface = uaa->iface;
usc->flags = athn_usb_lookup(uaa->vendor, uaa->product)->flags;
sc->flags |= ATHN_FLAG_USB;
@@ -251,20 +251,6 @@ athn_usb_attach(struct device *parent, struct device *self, void *aux)
usb_init_task(&usc->sc_task, athn_usb_task, sc, USB_TASK_TYPE_GENERIC);
- if (usbd_set_config_no(usc->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(usc->sc_udev, 0, &usc->sc_iface);
- if (error != 0) {
- printf("%s: could not get interface handle\n",
- sc->sc_dev.dv_xname);
- return;
- }
-
if (athn_usb_open_pipes(usc) != 0)
return;