I've been looking how to avoid '#include "[fu]_*.c"' and I think I start with common code for the creation / handling of descriptors.
I don't understand why each / most gadget set f->hs_descriptors and f->ss_descriptors depending on the gadget speed. This makes no sense as composite does not "leak" SS descriptors if the device operates has HS speed. So removing these speed checks wouldn't hurt and should make the code easier. The next thing is what we do with each descriptor. They are global and yet we update some of them: We set string ids, interface id and endpoint address. This is something each gadget does on its own. Looking closer at those descriptors there is a common pattern: The SS descriptors contain all possible USB descriptors for a given subset. The HS descriptors are the same as SS except they don't have a composite descriptor and the max packet size is smaller. The FS descriptors are the same as HS except for the max packet size. The endpoint address is the same for each endpoint of the same class (read as the first in the FS-set, HS-set, SS-set share the same endpoint address). The address can be also shared across alternative settings since both can't be used at the same time. I've been looking at this for a while but it seems like a good idea to provide one descriptor set per function and let composite assign the dynamic values like endpoint address,…. This would get rid of the global variables and make creation of descriptors easier / with less code. Sebastian -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html