summaryrefslogtreecommitdiff
path: root/include/linux/usb.h
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-03-17 13:35:31 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-23 15:53:16 +0300
commit279daf4e053470f22c9421a4ab05f8e5a9e9eeec (patch)
treec516a41b345a0fc41b2757e89d4a7d82e8c3166d /include/linux/usb.h
parent66a359390e7e34f9a4c489467234b107b3d76169 (diff)
downloadlinux-279daf4e053470f22c9421a4ab05f8e5a9e9eeec.tar.xz
USB: core: add helpers to retrieve endpoints in reverse order
Several 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, add corresponding helpers to lookup endpoints by searching the endpoint descriptors in reverse order. Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/usb.h')
-rw-r--r--include/linux/usb.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 7041cc950737..226557362d36 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -106,6 +106,13 @@ usb_find_common_endpoints(struct usb_host_interface *alt,
struct usb_endpoint_descriptor **int_in,
struct usb_endpoint_descriptor **int_out);
+int __must_check
+usb_find_common_endpoints_reverse(struct usb_host_interface *alt,
+ struct usb_endpoint_descriptor **bulk_in,
+ struct usb_endpoint_descriptor **bulk_out,
+ struct usb_endpoint_descriptor **int_in,
+ struct usb_endpoint_descriptor **int_out);
+
static inline int __must_check
usb_find_bulk_in_endpoint(struct usb_host_interface *alt,
struct usb_endpoint_descriptor **bulk_in)
@@ -134,6 +141,34 @@ usb_find_int_out_endpoint(struct usb_host_interface *alt,
return usb_find_common_endpoints(alt, NULL, NULL, NULL, int_out);
}
+static inline int __must_check
+usb_find_last_bulk_in_endpoint(struct usb_host_interface *alt,
+ struct usb_endpoint_descriptor **bulk_in)
+{
+ return usb_find_common_endpoints_reverse(alt, bulk_in, NULL, NULL, NULL);
+}
+
+static inline int __must_check
+usb_find_last_bulk_out_endpoint(struct usb_host_interface *alt,
+ struct usb_endpoint_descriptor **bulk_out)
+{
+ return usb_find_common_endpoints_reverse(alt, NULL, bulk_out, NULL, NULL);
+}
+
+static inline int __must_check
+usb_find_last_int_in_endpoint(struct usb_host_interface *alt,
+ struct usb_endpoint_descriptor **int_in)
+{
+ return usb_find_common_endpoints_reverse(alt, NULL, NULL, int_in, NULL);
+}
+
+static inline int __must_check
+usb_find_last_int_out_endpoint(struct usb_host_interface *alt,
+ struct usb_endpoint_descriptor **int_out)
+{
+ return usb_find_common_endpoints_reverse(alt, NULL, NULL, NULL, int_out);
+}
+
/**
* struct usb_interface - what usb device drivers talk to
* @altsetting: array of interface structures, one for each alternate