Apropos of the change to usb_epnum_to_ep_desc(), what about the function usb_ifnum_to_if()? It includes a comment saying (in a slightly misleading fashion) that devices are not required to transmit interface descriptors in order by interface number, and it performs a search for the requested interface.
There are devices that send interface descriptors in other orders. For example, the AMBIT USB Cable modem passes interface 1 then 0.
The only reason I've been able to come up with preventing config.c from reordering these is that some devices could be broken enough to break the rule that N interfaces have are numbered 0..(N-1) ... in which case the array indexing model wouldn't work. (We know it fails for configurations, since the configuration numbers aren't designed to be indexes; a single config could be numbered 255 for example.)
I'm not so sure that comment is right. For that matter, it seems likely that devices _are_ required to transmit different altsetting descriptors for an interface in numerical order. At least, that's how I interpret this paragraph from section 9.6.5 of the USB 2.0 spec:
Me too ... but then, some people writing device firmware don't bother to pay attention to specs.
Now I admit that's not as definitive as it could be. However, there are also comments in include/linux/usb.h that are quite clear. Under the definition of struct usb_interface it says (ungrammatically and with an off-by-one error):
* @altsetting: array of interface descriptors, one for each alternate * setting that may be selected. Each one includes a set of * endpoint configurations and will be in numberic order, * 0..num_altsetting.
Is "config.c" actually sorting that? Right now I'm assuming it isn't.
And under the definition of struct usb_host_config it says:
/* the interfaces associated with this configuration * these will be in numeric order, 0..desc.bNumInterfaces */ struct usb_interface *interface[USB_MAXINTERFACES];
Assuming these comments are correct, there's no need for usb_ifnum_to_if() to perform its search. In fact, there's no real need for the function at all; it could easily be inlined or eliminated entirely. However, there doesn't appear to be any code in core/config.c that verifies the descriptors are in numerical order or sorts them if they aren't. Maybe _that_ needs to be fixed.
You're right. I may be at fault for some of that text asserting they're ordered. But right now it's clear there's nothing enforcing an order, so it seems to me that all code should be using an accessor function that knows how to cope with out-of-order config, interface, altsetting, or endpoint descriptors ...
- Dave
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
