backports: add usb_endpoint_maxp()
authorPatrick Ziegler <patrick.ziegler@fh-kl.de>
Thu, 15 Aug 2013 12:40:26 +0000 (14:40 +0200)
committerLuis R. Rodriguez <mcgrof@do-not-panic.com>
Fri, 16 Aug 2013 02:56:27 +0000 (19:56 -0700)
This function is missing for kernel version < 3.2 but required by uvc_video
and cdc-wdm device drivers.

Signed-off-by: Patrick Ziegler <patrick.ziegler@fh-kl.de>
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
backport/backport-include/linux/usb/ch9.h [new file with mode: 0644]

diff --git a/backport/backport-include/linux/usb/ch9.h b/backport/backport-include/linux/usb/ch9.h
new file mode 100644 (file)
index 0000000..252a6f1
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef __BACKPORT__LINUX_USB_CH9_H
+#define __BACKPORT__LINUX_USB_CH9_H
+
+#include_next <linux/usb/ch9.h>
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)
+#include <linux/types.h>    /* __u8 etc */
+#include <asm/byteorder.h>  /* le16_to_cpu */
+
+/**
+ * usb_endpoint_maxp - get endpoint's max packet size
+ * @epd: endpoint to be checked
+ *
+ * Returns @epd's max packet
+ */
+static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd)
+{
+       return __le16_to_cpu(epd->wMaxPacketSize);
+}
+#endif /* < 3.2 */
+
+#endif /* __BACKPORT__LINUX_USB_CH9_H */