From 4e6c852a1208b2429dad46083c4befb5cb764430 Mon Sep 17 00:00:00 2001 From: damien Date: Fri, 8 Jul 2005 19:19:06 +0000 Subject: [PATCH] Make sure that all the necessary USB endpoints are found during device attachment. Reviewed by: silby (mentor) Approved by: re (scottl) --- sys/dev/usb/if_ural.c | 5 +++++ sys/dev/usb/if_uralvar.h | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/dev/usb/if_ural.c b/sys/dev/usb/if_ural.c index 3e60518f9840..ee2348c36dc3 100644 --- a/sys/dev/usb/if_ural.c +++ b/sys/dev/usb/if_ural.c @@ -388,6 +388,7 @@ USB_ATTACH(ural) */ id = usbd_get_interface_descriptor(sc->sc_iface); + sc->sc_rx_no = sc->sc_tx_no = -1; for (i = 0; i < id->bNumEndpoints; i++) { ed = usbd_interface2endpoint_descriptor(sc->sc_iface, i); if (ed == NULL) { @@ -403,6 +404,10 @@ USB_ATTACH(ural) UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) sc->sc_tx_no = ed->bEndpointAddress; } + if (sc->sc_rx_no == -1 || sc->sc_tx_no == -1) { + printf("%s: missing endpoint\n", USBDEVNAME(sc->sc_dev)); + USB_ATTACH_ERROR_RETURN; + } mtx_init(&sc->sc_mtx, USBDEVNAME(sc->sc_dev), MTX_NETWORK_LOCK, MTX_DEF | MTX_RECURSE); diff --git a/sys/dev/usb/if_uralvar.h b/sys/dev/usb/if_uralvar.h index 634c3db0c66e..160ad0d5c7d4 100644 --- a/sys/dev/usb/if_uralvar.h +++ b/sys/dev/usb/if_uralvar.h @@ -76,8 +76,8 @@ struct ural_softc { usbd_device_handle sc_udev; usbd_interface_handle sc_iface; - uint8_t sc_rx_no; - uint8_t sc_tx_no; + int sc_rx_no; + int sc_tx_no; uint32_t asic_rev; uint8_t rf_rev;