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 the two USBTMC fixes I submitted yesterday. Johan Johan Hovold (16): USB: core: add helpers to retrieve endpoints USB: core: add helpers to retrieve endpoints in reverse order USB: adutux: refactor endpoint retrieval USB: appledisplay: refactor endpoint retrieval USB: chaoskey: refactor endpoint retrieval USB: ftdi-elan: refactor endpoint retrieval USB: idmouse: refactor endpoint retrieval USB: iowarrior: refactor endpoint retrieval USB: ldusb: refactor endpoint retrieval USB: legousbtower: refactor endpoint retrieval USB: lvstest: tighten endpoint sanity check USB: usblcd: refactor endpoint retrieval USB: uss720: add debug endpoint-type check USB: yurex: refactor endpoint retrieval USB: usbtmc: refactor endpoint retrieval USB: usb-skeleton: refactor endpoint retrieval drivers/usb/class/usbtmc.c | 56 ++++++------------ drivers/usb/core/usb.c | 127 ++++++++++++++++++++++++++++++++++++++++ drivers/usb/misc/adutux.c | 38 ++++-------- drivers/usb/misc/appledisplay.c | 19 ++---- drivers/usb/misc/chaoskey.c | 23 ++++---- drivers/usb/misc/ftdi-elan.c | 42 ++++++------- drivers/usb/misc/idmouse.c | 31 ++++------ drivers/usb/misc/iowarrior.c | 24 +++----- drivers/usb/misc/ldusb.c | 23 +++----- drivers/usb/misc/legousbtower.c | 29 +++------ drivers/usb/misc/lvstest.c | 7 +-- drivers/usb/misc/usblcd.c | 47 ++++++--------- drivers/usb/misc/uss720.c | 10 ++-- drivers/usb/misc/yurex.c | 15 ++--- drivers/usb/usb-skeleton.c | 59 ++++++++----------- include/linux/usb.h | 70 ++++++++++++++++++++++ 16 files changed, 351 insertions(+), 269 deletions(-) -- 2.12.0 -- 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