diff options
author | 2015-06-12 15:47:31 +0000 | |
---|---|---|
committer | 2015-06-12 15:47:31 +0000 | |
commit | 7ebc5b51da5611c78123bf2a163bb4cee0fee6d5 (patch) | |
tree | 9e2efe12c6dafc889c8722d6cffa0d9c8496d325 /sys/dev/usb/if_run.c | |
parent | Remove superfluous splnet() protection. (diff) | |
download | wireguard-openbsd-7ebc5b51da5611c78123bf2a163bb4cee0fee6d5.tar.xz wireguard-openbsd-7ebc5b51da5611c78123bf2a163bb4cee0fee6d5.zip |
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_run.c')
-rw-r--r-- | sys/dev/usb/if_run.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/sys/dev/usb/if_run.c b/sys/dev/usb/if_run.c index 5c3ffc3cf2c..73c87bf0889 100644 --- a/sys/dev/usb/if_run.c +++ b/sys/dev/usb/if_run.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_run.c,v 1.108 2015/03/14 03:38:49 jsg Exp $ */ +/* $OpenBSD: if_run.c,v 1.109 2015/06/12 15:47:31 mpi Exp $ */ /*- * Copyright (c) 2008-2010 Damien Bergamini <damien.bergamini@free.fr> @@ -518,11 +518,11 @@ run_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(run_devs, uaa->vendor, uaa->product) != NULL) ? - UMATCH_VENDOR_PRODUCT : UMATCH_NONE; + UMATCH_VENDOR_PRODUCT_CONF_IFACE : UMATCH_NONE; } void @@ -534,24 +534,11 @@ run_attach(struct device *parent, struct device *self, void *aux) struct ifnet *ifp = &ic->ic_if; usb_interface_descriptor_t *id; usb_endpoint_descriptor_t *ed; - int i, nrx, ntx, ntries, error; + int i, nrx, ntx, ntries; uint32_t ver; sc->sc_udev = uaa->device; - - 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; - } + sc->sc_iface = uaa->iface; /* * Find all bulk endpoints. There are 7 bulk endpoints: 1 for RX |