From: mpi Date: Thu, 18 Jun 2015 09:28:54 +0000 (+0000) Subject: Only match devices with a valid configuration. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f8ef4bb861984ce0312f4e8ab409d07a0c29e85d;p=openbsd 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. Tested by jsg@ --- diff --git a/sys/dev/usb/if_smsc.c b/sys/dev/usb/if_smsc.c index 53097e84889..697d436aa10 100644 --- a/sys/dev/usb/if_smsc.c +++ b/sys/dev/usb/if_smsc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_smsc.c,v 1.18 2015/03/23 22:48:51 jsg Exp $ */ +/* $OpenBSD: if_smsc.c,v 1.19 2015/06/18 09:28:54 mpi Exp $ */ /* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ /*- * Copyright (c) 2012 @@ -911,11 +911,11 @@ smsc_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(smsc_devs, uaa->vendor, uaa->product) != NULL) ? - UMATCH_VENDOR_PRODUCT : UMATCH_NONE; + UMATCH_VENDOR_PRODUCT_CONF_IFACE : UMATCH_NONE; } void @@ -923,17 +923,15 @@ smsc_attach(struct device *parent, struct device *self, void *aux) { struct smsc_softc *sc = (struct smsc_softc *)self; struct usb_attach_arg *uaa = aux; - struct usbd_device *dev = uaa->device; usb_interface_descriptor_t *id; usb_endpoint_descriptor_t *ed; struct mii_data *mii; struct ifnet *ifp; - int err, s, i; uint32_t mac_h, mac_l; + int s, i; - sc->sc_udev = dev; - - err = usbd_set_config_no(dev, SMSC_CONFIG_INDEX, 1); + sc->sc_udev = uaa->device; + sc->sc_iface = uaa->iface; /* Setup the endpoints for the SMSC LAN95xx device(s) */ usb_init_task(&sc->sc_tick_task, smsc_tick_task, sc, @@ -942,13 +940,6 @@ smsc_attach(struct device *parent, struct device *self, void *aux) usb_init_task(&sc->sc_stop_task, (void (*)(void *))smsc_stop, sc, USB_TASK_TYPE_GENERIC); - err = usbd_device2interface_handle(dev, SMSC_IFACE_IDX, &sc->sc_iface); - if (err) { - printf("%s: getting interface handle failed\n", - sc->sc_dev.dv_xname); - return; - } - id = usbd_get_interface_descriptor(sc->sc_iface); if (sc->sc_udev->speed >= USB_SPEED_HIGH) diff --git a/sys/dev/usb/if_smscreg.h b/sys/dev/usb/if_smscreg.h index a5ee3c6649b..6172657a038 100644 --- a/sys/dev/usb/if_smscreg.h +++ b/sys/dev/usb/if_smscreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_smscreg.h,v 1.4 2013/04/15 09:23:01 mglocker Exp $ */ +/* $OpenBSD: if_smscreg.h,v 1.5 2015/06/18 09:28:54 mpi Exp $ */ /*- * Copyright (c) 2012 * Ben Gray . @@ -241,9 +241,6 @@ #define SMSC_RX_LIST_CNT 1 #define SMSC_TX_LIST_CNT 1 -#define SMSC_CONFIG_INDEX 1 /* config number 1 */ -#define SMSC_IFACE_IDX 0 - #define SMSC_ENDPT_RX 0 #define SMSC_ENDPT_TX 1 #define SMSC_ENDPT_INTR 2