On Fri, Mar 17, 2017 at 11:35:29AM +0100, Johan Hovold wrote: > Many USB drivers iterate over the available endpoints to find required > endpoints of a specific type and direction. Typically the endpoints are > required for proper function and a missing endpoint should abort probe. > > To facilitate code reuse, this series adds a helper to retrieve common > endpoints (bulk or interrupt, in or out) and four wrappers to find a > single endpoint (which should cover the vast majority of drivers). > > This typically saves about 10-15 lines of code per driver, so even if > this series result in a net gain in terms of lines due to the helpers > being added to core, there will be further reductions when applied to > other subsystems. > > Note that the helpers are marked as __must_check to serve as a reminder > to always verify that all expected endpoints are indeed present. > > Also note that some drivers have implemented their endpoint look-up > loops in such a way that they have picked the last endpoint descriptor > of the specified type should more than one such descriptor exist. To > avoid any regressions, the second patch therefore adds corresponding > helpers to lookup endpoints by searching the endpoint descriptors in > reverse order. In almost all cases, I expect it would be safe to simply > pick the first matching descriptor instead (i.e. there is only one > endpoint descriptor per type). > > Note that this series applies on top of Greg's usb-linus branch which > has a few fixes for the iowarrior and USBTMC drivers. I applied this to my usb-next branch, which is probably why a few didn't apply properly. Let's get usb-linus merged with Linus, and then merged together on Monday and then can you resend those remaining two? Oh, and thanks for doing this. I doubt the reverse functions are really needed, but it can't hurt to be safe here, so I appreciate that. All now queued up. greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html