1
votes

I am understanding usb_new_device() function. I have a question related to usb_enumerate_device() function calling inside usb_new_device().

As per the comments above the function, it reads configs/intfs/otg. But I didn't see in the function definition that it is reading the interface descriptor.

It seems the function is reading config descriptor and doing something for OTG devices. I am not seeing the source related to interface descriptor reading. I am missing something here. linux

usb_enumerate_device() => usb_get_configuration() => usb_parse_configuration() => usb_parse_interface(). - Ian Abbott
I think usb_parse_configuration() and usb_parse_interface() functions are to parse the descriptors, which already read from the device. I could see usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,bigbuffer,length) call inside usb_get_configuration() is submitting control message to the device to read configuration descriptor. As the comment against usb_enumerate_device() says Read descriptors, I am looking for a call to usb_get_descriptor() with USB_DT_INTERFACE as argument. - user3693586
The interface descriptors and endpoint descriptors are embedded in the configuration descriptor. - Ian Abbott
As it says in section 9.4.3 of the USB 3.1 spec, "The standard request to a device supports four types of descriptors: device, configuration, BOS (Binary device Object Store), and string." (For USB 2.0 there are no BOS descriptors, so only three types of descriptors are supported.) - Ian Abbott
And in the same section, "A request for a configuration descriptor returns the configuration descriptor, all interface descriptors, endpoint descriptors and endpoint companion descriptors (when operating at Gen X speed) for all of the interfaces in a single request." - Ian Abbott