The elements of these structures are only explained in detail as far as they are necessary for subsequent API calls. Detailed information about the descriptors can be found in usb.h and [4] section 9.5.
struct usb_device{ ... struct usb_config_descriptor *actconfig;/* the active configuration */ ... struct usb_device_descriptor descriptor;/* Descriptor */ struct usb_config_descriptor *config; /* All of the configs */ }The usb_device structure is the root of all USB specific descriptors. Sometimes it is necessary to parse the descriptors within a driver to configure the device or to setup transfer requests properly.
for (i = 0; i < dev->descriptor.bNumConfigurations; i++) { struct usb_config_descriptor *cfg = &dev->config[i]; ... }
for (j = 0; j < cfg->bNumInterfaces; j++) { struct usb_interface *ifp = &cfg->interface[j]; ... }To start the parsing of the active configuration simply use the dev->actconfig pointer.
for (k = 0; k < ifp->num_altsetting; k++) { struct usb_interface_descriptor *as = &ifp->altsetting[k]; ... }
The active alternate setting can be accessed via
*as = &ifp->altsetting[ifp->act_altsetting]
for(l = 0; l < as->bNumEndpoints; l++) { struct usb_endpoint_descriptor *ep=&as->endpoint[k]; ... }