From cb4c8d6490adef1ec8be69931ba50e6b4edb9f27 Mon Sep 17 00:00:00 2001 From: mpi Date: Thu, 18 Jun 2015 10:02:49 +0000 Subject: [PATCH] Only match devices with a valid configuration. Tested by jsg@ --- sys/dev/usb/if_aue.c | 23 ++++------------------- sys/dev/usb/if_auereg.h | 5 +---- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/sys/dev/usb/if_aue.c b/sys/dev/usb/if_aue.c index 9ae414f18b5..bb69039722b 100644 --- a/sys/dev/usb/if_aue.c +++ b/sys/dev/usb/if_aue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_aue.c,v 1.98 2015/03/24 10:02:18 mpi Exp $ */ +/* $OpenBSD: if_aue.c,v 1.99 2015/06/18 10:02:49 mpi Exp $ */ /* $NetBSD: if_aue.c,v 1.82 2003/03/05 17:37:36 shiba Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -684,11 +684,11 @@ aue_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 (aue_lookup(uaa->vendor, uaa->product) != NULL ? - UMATCH_VENDOR_PRODUCT : UMATCH_NONE); + UMATCH_VENDOR_PRODUCT_CONF_IFACE : UMATCH_NONE); } /* @@ -705,8 +705,7 @@ aue_attach(struct device *parent, struct device *self, void *aux) struct ifnet *ifp; struct mii_data *mii; struct usbd_device *dev = uaa->device; - struct usbd_interface *iface; - usbd_status err; + struct usbd_interface *iface = uaa->iface; usb_interface_descriptor_t *id; usb_endpoint_descriptor_t *ed; int i; @@ -715,26 +714,12 @@ aue_attach(struct device *parent, struct device *self, void *aux) sc->aue_udev = dev; - err = usbd_set_config_no(dev, AUE_CONFIG_NO, 1); - if (err) { - printf("%s: setting config no failed\n", - sc->aue_dev.dv_xname); - return; - } - usb_init_task(&sc->aue_tick_task, aue_tick_task, sc, USB_TASK_TYPE_GENERIC); usb_init_task(&sc->aue_stop_task, (void (*)(void *))aue_stop, sc, USB_TASK_TYPE_GENERIC); rw_init(&sc->aue_mii_lock, "auemii"); - err = usbd_device2interface_handle(dev, AUE_IFACE_IDX, &iface); - if (err) { - printf("%s: getting interface handle failed\n", - sc->aue_dev.dv_xname); - return; - } - sc->aue_flags = aue_lookup(uaa->vendor, uaa->product)->aue_flags; sc->aue_iface = iface; diff --git a/sys/dev/usb/if_auereg.h b/sys/dev/usb/if_auereg.h index 5e31de93d33..14b69d6b260 100644 --- a/sys/dev/usb/if_auereg.h +++ b/sys/dev/usb/if_auereg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_auereg.h,v 1.17 2013/12/13 01:13:56 brad Exp $ */ +/* $OpenBSD: if_auereg.h,v 1.18 2015/06/18 10:02:49 mpi Exp $ */ /* $NetBSD: if_auereg.h,v 1.16 2001/10/10 02:14:17 augustss Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -51,9 +51,6 @@ #define AUE_UR_READREG 0xF0 #define AUE_UR_WRITEREG 0xF1 -#define AUE_CONFIG_NO 1 -#define AUE_IFACE_IDX 0 - /* * Note that while the ADMtek technically has four * endpoints, the control endpoint (endpoint 0) is -- 2.20.1