Lines Matching +full:usb +full:- +full:valid
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2008-2020 Hans Petter Selasky. All rights reserved.
50 #include <dev/usb/usb.h>
51 #include <dev/usb/usbdi.h>
52 #include <dev/usb/usbdi_util.h>
56 #include <dev/usb/usb_core.h>
57 #include <dev/usb/usb_debug.h>
60 /*------------------------------------------------------------------------*
63 * This function is the safe way to iterate across the USB config
71 *------------------------------------------------------------------------*/
87 end = start + UGETW(cd->wTotalLength); in usb_desc_foreach()
90 /* Get start of next USB descriptor. */ in usb_desc_foreach()
96 /* Check that the next USB descriptor is within the range. */ in usb_desc_foreach()
100 /* Check that the second next USB descriptor is within range. */ in usb_desc_foreach()
113 /*------------------------------------------------------------------------*
122 * Else: A valid interface descriptor
123 *------------------------------------------------------------------------*/
132 id = (struct usb_interface_descriptor *)ps->desc; in usb_idesc_foreach()
141 if ((id->bDescriptorType == UDESC_INTERFACE) && in usb_idesc_foreach()
142 (id->bLength >= sizeof(*id))) { in usb_idesc_foreach()
143 if (ps->iface_no_last == id->bInterfaceNumber) { in usb_idesc_foreach()
147 * alternate index which is a 8-bit in usb_idesc_foreach()
150 if (ps->iface_index_alt == 255) { in usb_idesc_foreach()
152 id->bInterfaceNumber); in usb_idesc_foreach()
157 ps->iface_no_last = id->bInterfaceNumber; in usb_idesc_foreach()
162 if (ps->desc == NULL) { in usb_idesc_foreach()
166 ps->iface_index ++; in usb_idesc_foreach()
167 ps->iface_index_alt = 0; in usb_idesc_foreach()
170 ps->iface_index_alt ++; in usb_idesc_foreach()
176 if (ps->iface_index >= USB_IFACE_MAX) { in usb_idesc_foreach()
182 ps->desc = (struct usb_descriptor *)id; in usb_idesc_foreach()
186 /*------------------------------------------------------------------------*
191 * be a valid interface descriptor.
195 * Else: A valid endpoint descriptor
196 *------------------------------------------------------------------------*/
206 if (desc->bDescriptorType == UDESC_INTERFACE) { in usb_edesc_foreach()
209 if (desc->bDescriptorType == UDESC_ENDPOINT) { in usb_edesc_foreach()
210 if (desc->bLength < sizeof(*ped)) { in usb_edesc_foreach()
220 /*------------------------------------------------------------------------*
225 * value for the "ped" argument should be a valid endpoint companion
230 * Else: A valid endpoint companion descriptor
231 *------------------------------------------------------------------------*/
241 if (desc->bDescriptorType == UDESC_INTERFACE) in usb_ed_comp_foreach()
243 if (desc->bDescriptorType == UDESC_ENDPOINT) in usb_ed_comp_foreach()
245 if (desc->bDescriptorType == UDESC_ENDPOINT_SS_COMP) { in usb_ed_comp_foreach()
246 if (desc->bLength < sizeof(*ped)) { in usb_ed_comp_foreach()
256 /*------------------------------------------------------------------------*
261 *------------------------------------------------------------------------*/
269 if (desc->bDescriptorType == type) { in usbd_get_no_descriptors()
278 /*------------------------------------------------------------------------*
283 * pointer. If the USB descriptor is corrupt, the returned value can
285 *------------------------------------------------------------------------*/
300 ifaceno = id->bInterfaceNumber; in usbd_get_no_alts()
302 /* Iterate all the USB descriptors */ in usbd_get_no_alts()
306 if ((desc->bDescriptorType == UDESC_INTERFACE) && in usbd_get_no_alts()
307 (desc->bLength >= sizeof(*id))) { in usbd_get_no_alts()
309 if (id->bInterfaceNumber == ifaceno) { in usbd_get_no_alts()