@@ -3,7 +3,11 @@
#include_next <linux/usb.h>
#include <linux/version.h>
-#if LINUX_VERSION_IS_LESS(5,15,0)
+#if LINUX_VERSION_IS_LESS(6,3,5) && \
+ !LINUX_VERSION_IN_RANGE(6,1,31, 6,2,0) && \
+ !LINUX_VERSION_IN_RANGE(5,15,114, 5,16,0) && \
+ !LINUX_VERSION_IN_RANGE(5,10,181, 5,11,0) && \
+ !LINUX_VERSION_IN_RANGE(5,4,244, 5,5,0)
#define usb_check_bulk_endpoints LINUX_BACKPORT(usb_check_bulk_endpoints)
bool usb_check_bulk_endpoints(
const struct usb_interface *intf, const u8 *ep_addrs);
@@ -17,4 +17,5 @@ compat-$(CPTCFG_KERNEL_5_10) += backport-5.10.o
compat-$(CPTCFG_KERNEL_5_11) += backport-5.11.o
compat-$(CPTCFG_KERNEL_5_13) += backport-5.13.o
compat-$(CPTCFG_KERNEL_5_15) += backport-5.15.o
+compat-$(CPTCFG_KERNEL_6_4) += backport-6.4.o
@@ -4,7 +4,6 @@
#include <linux/export.h>
#include <linux/uaccess.h>
#include <linux/netdevice.h>
-#include <linux/usb.h>
#include <uapi/linux/if.h>
@@ -51,54 +50,3 @@ int put_user_ifreq(struct ifreq *ifr, void __user *arg)
return 0;
}
EXPORT_SYMBOL(put_user_ifreq);
-
-
-/**
- * usb_find_endpoint() - Given an endpoint address, search for the endpoint's
- * usb_host_endpoint structure in an interface's current altsetting.
- * @intf: the interface whose current altsetting should be searched
- * @ep_addr: the endpoint address (number and direction) to find
- *
- * Search the altsetting's list of endpoints for one with the specified address.
- *
- * Return: Pointer to the usb_host_endpoint if found, %NULL otherwise.
- */
-static const struct usb_host_endpoint *usb_find_endpoint(
- const struct usb_interface *intf, unsigned int ep_addr)
-{
- int n;
- const struct usb_host_endpoint *ep;
-
- n = intf->cur_altsetting->desc.bNumEndpoints;
- ep = intf->cur_altsetting->endpoint;
- for (; n > 0; (--n, ++ep)) {
- if (ep->desc.bEndpointAddress == ep_addr)
- return ep;
- }
- return NULL;
-}
-
-/**
- * usb_check_bulk_endpoints - Check whether an interface's current altsetting
- * contains a set of bulk endpoints with the given addresses.
- * @intf: the interface whose current altsetting should be searched
- * @ep_addrs: 0-terminated array of the endpoint addresses (number and
- * direction) to look for
- *
- * Search for endpoints with the specified addresses and check their types.
- *
- * Return: %true if all the endpoints are found and are bulk, %false otherwise.
- */
-bool usb_check_bulk_endpoints(
- const struct usb_interface *intf, const u8 *ep_addrs)
-{
- const struct usb_host_endpoint *ep;
-
- for (; *ep_addrs; ++ep_addrs) {
- ep = usb_find_endpoint(intf, *ep_addrs);
- if (!ep || !usb_endpoint_xfer_bulk(&ep->desc))
- return false;
- }
- return true;
-}
-EXPORT_SYMBOL_GPL(usb_check_bulk_endpoints);
new file mode 100644
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/export.h>
+#include <linux/usb.h>
+
+#if LINUX_VERSION_IS_LESS(6,3,5) && \
+ !LINUX_VERSION_IN_RANGE(6,1,31, 6,2,0) && \
+ !LINUX_VERSION_IN_RANGE(5,15,114, 5,16,0) && \
+ !LINUX_VERSION_IN_RANGE(5,10,181, 5,11,0) && \
+ !LINUX_VERSION_IN_RANGE(5,4,244, 5,5,0)
+
+/**
+ * usb_find_endpoint() - Given an endpoint address, search for the endpoint's
+ * usb_host_endpoint structure in an interface's current altsetting.
+ * @intf: the interface whose current altsetting should be searched
+ * @ep_addr: the endpoint address (number and direction) to find
+ *
+ * Search the altsetting's list of endpoints for one with the specified address.
+ *
+ * Return: Pointer to the usb_host_endpoint if found, %NULL otherwise.
+ */
+static const struct usb_host_endpoint *usb_find_endpoint(
+ const struct usb_interface *intf, unsigned int ep_addr)
+{
+ int n;
+ const struct usb_host_endpoint *ep;
+
+ n = intf->cur_altsetting->desc.bNumEndpoints;
+ ep = intf->cur_altsetting->endpoint;
+ for (; n > 0; (--n, ++ep)) {
+ if (ep->desc.bEndpointAddress == ep_addr)
+ return ep;
+ }
+ return NULL;
+}
+
+/**
+ * usb_check_bulk_endpoints - Check whether an interface's current altsetting
+ * contains a set of bulk endpoints with the given addresses.
+ * @intf: the interface whose current altsetting should be searched
+ * @ep_addrs: 0-terminated array of the endpoint addresses (number and
+ * direction) to look for
+ *
+ * Search for endpoints with the specified addresses and check their types.
+ *
+ * Return: %true if all the endpoints are found and are bulk, %false otherwise.
+ */
+bool usb_check_bulk_endpoints(
+ const struct usb_interface *intf, const u8 *ep_addrs)
+{
+ const struct usb_host_endpoint *ep;
+
+ for (; *ep_addrs; ++ep_addrs) {
+ ep = usb_find_endpoint(intf, *ep_addrs);
+ if (!ep || !usb_endpoint_xfer_bulk(&ep->desc))
+ return false;
+ }
+ return true;
+}
+EXPORT_SYMBOL_GPL(usb_check_bulk_endpoints);
+#endif
usb_check_bulk_endpoints() was added in kernel 6.4 and then backported to older kernel versions. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> --- backport/backport-include/linux/usb.h | 6 ++- backport/compat/Makefile | 1 + backport/compat/backport-5.15.c | 52 ----------------------- backport/compat/backport-6.4.c | 61 +++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 53 deletions(-) create mode 100644 backport/compat/backport-6.4.c