!12 Update to libusbx-1.0.24
From: @wenchao-hao Reviewed-by: @liuzhiqiang26 Signed-off-by: @liuzhiqiang26
This commit is contained in:
commit
5df1c260d8
@ -1,28 +0,0 @@
|
|||||||
From 648ac1b5cae17b4b874715eb242bad6d725bc23b Mon Sep 17 00:00:00 2001
|
|
||||||
From: mrstock <info@niub.it>
|
|
||||||
Date: Fri, 20 Sep 2019 14:36:07 +0200
|
|
||||||
Subject: [PATCH 1/8] fix constant not in range of enumerated type
|
|
||||||
|
|
||||||
fix "Integer constant not in range of enumerated type 'enum libusb_transfer_status'"
|
|
||||||
|
|
||||||
LIBUSB_ERROR_NO_DEVICE doesn't exist on enum libusb_transfer_status
|
|
||||||
---
|
|
||||||
libusb/sync.c | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/libusb/sync.c b/libusb/sync.c
|
|
||||||
index 70942ac..863fe5c 100644
|
|
||||||
--- a/libusb/sync.c
|
|
||||||
+++ b/libusb/sync.c
|
|
||||||
@@ -62,7 +62,7 @@ static void sync_transfer_wait_for_completion(struct libusb_transfer *transfer)
|
|
||||||
}
|
|
||||||
if (NULL == transfer->dev_handle) {
|
|
||||||
/* transfer completion after libusb_close() */
|
|
||||||
- transfer->status = LIBUSB_ERROR_NO_DEVICE;
|
|
||||||
+ transfer->status = LIBUSB_TRANSFER_NO_DEVICE;
|
|
||||||
*completed = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.27.0.windows.1
|
|
||||||
|
|
||||||
@ -1,134 +0,0 @@
|
|||||||
From 51d21bb84277df266003ed9403904c32f564693f Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kenjiro Tsuji <kenjiro.tsuji@oracle.com>
|
|
||||||
Date: Wed, 25 Sep 2019 17:51:43 -0700
|
|
||||||
Subject: [PATCH 2/8] Solaris backend is not correctly setting the one transfer
|
|
||||||
mode for Interrupt-In pipe
|
|
||||||
|
|
||||||
In sunos_check_device_and_status_open() function, if the target is an Interrupt-In
|
|
||||||
pipe, it opens the status endpoint first and writes USB_EP_INTR_ONE_XFER control
|
|
||||||
to the status endpoint to enable the one transfer mode. And it then closes the
|
|
||||||
status endpoint. After that, it opens the xfer endpoint and re-opens the status
|
|
||||||
endpoint. This is not correct, because closing the status endpoint is implicitly
|
|
||||||
disables the one tranfer mode. As a result, an event notification won't be
|
|
||||||
delivered to the client in timely manner. According to the comment in the source,
|
|
||||||
closing the status endpoint first and opening the xfer endpoint and status endpoint
|
|
||||||
in this order is intentional to avoit an issue that may happen if the USB device
|
|
||||||
has multiple configurations, which may be due to a ugen driver issue. To address
|
|
||||||
both issues, it can open the xfer endpoint first and immediately close it, which
|
|
||||||
will take care of the switch of configurations, if necessary. Then, it can open
|
|
||||||
the status endpoint, enable the one transfer mode, and re-open the xfer endpoint.
|
|
||||||
This is a fix of libusb#620.
|
|
||||||
|
|
||||||
Closes #629
|
|
||||||
|
|
||||||
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
||||||
---
|
|
||||||
libusb/os/sunos_usb.c | 69 ++++++++++++++++++++++++++-----------------
|
|
||||||
1 file changed, 42 insertions(+), 27 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/libusb/os/sunos_usb.c b/libusb/os/sunos_usb.c
|
|
||||||
index 6a3f633..c9a16fa 100644
|
|
||||||
--- a/libusb/os/sunos_usb.c
|
|
||||||
+++ b/libusb/os/sunos_usb.c
|
|
||||||
@@ -901,18 +901,50 @@ sunos_check_device_and_status_open(struct libusb_device_handle *hdl,
|
|
||||||
(void) snprintf(statfilename, PATH_MAX, "%sstat", filename);
|
|
||||||
|
|
||||||
/*
|
|
||||||
- * for interrupt IN endpoints, we need to enable one xfer
|
|
||||||
- * mode before opening the endpoint
|
|
||||||
+ * In case configuration has been switched, the xfer endpoint needs
|
|
||||||
+ * to be opened before the status endpoint, due to a ugen issue.
|
|
||||||
+ * However, to enable the one transfer mode for an Interrupt-In pipe,
|
|
||||||
+ * the status endpoint needs to be opened before the xfer endpoint.
|
|
||||||
+ * So, open the xfer mode first and close it immediately
|
|
||||||
+ * as a workaround. This will handle the configuration switch.
|
|
||||||
+ * Then, open the status endpoint. If for an Interrupt-in pipe,
|
|
||||||
+ * write the USB_EP_INTR_ONE_XFER control to the status endpoint
|
|
||||||
+ * to enable the one transfer mode. Then, re-open the xfer mode.
|
|
||||||
+ */
|
|
||||||
+ if (ep_type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS) {
|
|
||||||
+ mode = O_RDWR;
|
|
||||||
+ } else if (ep_addr & LIBUSB_ENDPOINT_IN) {
|
|
||||||
+ mode = O_RDONLY;
|
|
||||||
+ } else {
|
|
||||||
+ mode = O_WRONLY;
|
|
||||||
+ }
|
|
||||||
+ /* Open the xfer endpoint first */
|
|
||||||
+ if ((fd = open(filename, mode)) == -1) {
|
|
||||||
+ usbi_dbg("can't open %s: %d(%s)", filename, errno,
|
|
||||||
+ strerror(errno));
|
|
||||||
+
|
|
||||||
+ return (errno);
|
|
||||||
+ }
|
|
||||||
+ /* And immediately close the xfer endpoint */
|
|
||||||
+ (void) close(fd);
|
|
||||||
+
|
|
||||||
+ /*
|
|
||||||
+ * Open the status endpoint.
|
|
||||||
+ * If for an Interrupt-IN pipe, need to enable the one transfer mode
|
|
||||||
+ * by writing USB_EP_INTR_ONE_XFER control to the status endpoint
|
|
||||||
+ * before opening the xfer endpoint
|
|
||||||
*/
|
|
||||||
if ((ep_type == LIBUSB_TRANSFER_TYPE_INTERRUPT) &&
|
|
||||||
(ep_addr & LIBUSB_ENDPOINT_IN)) {
|
|
||||||
char control = USB_EP_INTR_ONE_XFER;
|
|
||||||
int count;
|
|
||||||
|
|
||||||
- /* open the status device node for the ep first RDWR */
|
|
||||||
+ /* Open the status endpoint with RDWR */
|
|
||||||
if ((fdstat = open(statfilename, O_RDWR)) == -1) {
|
|
||||||
usbi_dbg("can't open %s RDWR: %d",
|
|
||||||
statfilename, errno);
|
|
||||||
+
|
|
||||||
+ return (errno);
|
|
||||||
} else {
|
|
||||||
count = write(fdstat, &control, sizeof (control));
|
|
||||||
if (count != 1) {
|
|
||||||
@@ -923,37 +955,20 @@ sunos_check_device_and_status_open(struct libusb_device_handle *hdl,
|
|
||||||
|
|
||||||
return (errno);
|
|
||||||
}
|
|
||||||
- /* close status node and open xfer node first */
|
|
||||||
- close (fdstat);
|
|
||||||
}
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- /* open the xfer node first in case alt needs to be changed */
|
|
||||||
- if (ep_type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS) {
|
|
||||||
- mode = O_RDWR;
|
|
||||||
- } else if (ep_addr & LIBUSB_ENDPOINT_IN) {
|
|
||||||
- mode = O_RDONLY;
|
|
||||||
} else {
|
|
||||||
- mode = O_WRONLY;
|
|
||||||
+ if ((fdstat = open(statfilename, O_RDONLY)) == -1) {
|
|
||||||
+ usbi_dbg("can't open %s: %d", statfilename, errno);
|
|
||||||
+
|
|
||||||
+ return (errno);
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
- /*
|
|
||||||
- * IMPORTANT: must open data xfer node first and then open stat node
|
|
||||||
- * Otherwise, it will fail on multi-config or multi-altsetting devices
|
|
||||||
- * with "Device Busy" error. See ugen_epxs_switch_cfg_alt() and
|
|
||||||
- * ugen_epxs_check_alt_switch() in ugen driver source code.
|
|
||||||
- */
|
|
||||||
+ /* Re-open the xfer endpoint */
|
|
||||||
if ((fd = open(filename, mode)) == -1) {
|
|
||||||
usbi_dbg("can't open %s: %d(%s)", filename, errno,
|
|
||||||
strerror(errno));
|
|
||||||
-
|
|
||||||
- return (errno);
|
|
||||||
- }
|
|
||||||
- /* open the status node */
|
|
||||||
- if ((fdstat = open(statfilename, O_RDONLY)) == -1) {
|
|
||||||
- usbi_dbg("can't open %s: %d", statfilename, errno);
|
|
||||||
-
|
|
||||||
- (void) close(fd);
|
|
||||||
+ (void) close(fdstat);
|
|
||||||
|
|
||||||
return (errno);
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.27.0.windows.1
|
|
||||||
|
|
||||||
@ -1,64 +0,0 @@
|
|||||||
From af4cee9186e0a8d7c18a3ce40d215b3a1cd31d93 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kenjiro Tsuji <kenjiro.tsuji@oracle.com>
|
|
||||||
Date: Wed, 25 Sep 2019 17:11:12 -0700
|
|
||||||
Subject: [PATCH 3/8] Solaris: fails to find USB devices on SPARC platform
|
|
||||||
|
|
||||||
On SPARC platform, libusb fails to find USB devices. sunos_fill_in_dev_info()
|
|
||||||
reads the usb-dev-descriptor property and stores idVendor and idProduct to
|
|
||||||
the dev_sesc structure in little endian. However, when creating a device name
|
|
||||||
for 'match_str' to be specified to sunos_physpath_to_devlink(), it's using the
|
|
||||||
idVendor and idProduct in dev_descr as is without converting them to the host
|
|
||||||
endian, that is big endian for SPARC. As a result, 'match_str' has a wrong
|
|
||||||
device name and sunos_physpath_to_devlink() fails to find the device path
|
|
||||||
corresponding to the USB device. idVendor and idProduct need to be converted
|
|
||||||
to the host endian when creating 'match_str'.
|
|
||||||
This is a fix for #587.
|
|
||||||
|
|
||||||
Closes #628
|
|
||||||
|
|
||||||
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
||||||
---
|
|
||||||
libusb/os/sunos_usb.c | 13 +++++++++----
|
|
||||||
1 file changed, 9 insertions(+), 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/libusb/os/sunos_usb.c b/libusb/os/sunos_usb.c
|
|
||||||
index c9a16fa..185c371 100644
|
|
||||||
--- a/libusb/os/sunos_usb.c
|
|
||||||
+++ b/libusb/os/sunos_usb.c
|
|
||||||
@@ -411,8 +411,9 @@ sunos_detach_kernel_driver(struct libusb_device_handle *dev_handle,
|
|
||||||
if (r)
|
|
||||||
usbi_warn(HANDLE_CTX(dev_handle), "one or more ioctls failed");
|
|
||||||
|
|
||||||
- snprintf(path_arg, sizeof(path_arg), "^usb/%x.%x", dpriv->dev_descr.idVendor,
|
|
||||||
- dpriv->dev_descr.idProduct);
|
|
||||||
+ snprintf(path_arg, sizeof(path_arg), "^usb/%x.%x",
|
|
||||||
+ libusb_le16_to_cpu(dpriv->dev_descr.idVendor),
|
|
||||||
+ libusb_le16_to_cpu(dpriv->dev_descr.idProduct));
|
|
||||||
sunos_physpath_to_devlink(dpriv->phypath, path_arg, &dpriv->ugenpath);
|
|
||||||
|
|
||||||
if (access(dpriv->ugenpath, F_OK) == -1) {
|
|
||||||
@@ -526,7 +527,9 @@ sunos_fill_in_dev_info(di_node_t node, struct libusb_device *dev)
|
|
||||||
phypath = di_devfs_path(node);
|
|
||||||
if (phypath) {
|
|
||||||
dpriv->phypath = strdup(phypath);
|
|
||||||
- snprintf(match_str, sizeof(match_str), "^usb/%x.%x", dpriv->dev_descr.idVendor, dpriv->dev_descr.idProduct);
|
|
||||||
+ snprintf(match_str, sizeof(match_str), "^usb/%x.%x",
|
|
||||||
+ libusb_le16_to_cpu(dpriv->dev_descr.idVendor),
|
|
||||||
+ libusb_le16_to_cpu(dpriv->dev_descr.idProduct));
|
|
||||||
usbi_dbg("match is %s", match_str);
|
|
||||||
sunos_physpath_to_devlink(dpriv->phypath, match_str, &dpriv->ugenpath);
|
|
||||||
di_devfs_path_free(phypath);
|
|
||||||
@@ -557,7 +560,9 @@ sunos_fill_in_dev_info(di_node_t node, struct libusb_device *dev)
|
|
||||||
}
|
|
||||||
|
|
||||||
usbi_dbg("vid=%x pid=%x, path=%s, bus_nmber=0x%x, port_number=%d, "
|
|
||||||
- "speed=%d", dpriv->dev_descr.idVendor, dpriv->dev_descr.idProduct,
|
|
||||||
+ "speed=%d",
|
|
||||||
+ libusb_le16_to_cpu(dpriv->dev_descr.idVendor),
|
|
||||||
+ libusb_le16_to_cpu(dpriv->dev_descr.idProduct),
|
|
||||||
dpriv->phypath, dev->bus_number, dev->port_number, dev->speed);
|
|
||||||
|
|
||||||
return (LIBUSB_SUCCESS);
|
|
||||||
--
|
|
||||||
2.27.0.windows.1
|
|
||||||
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
From df7cb74443b31311bfc36977f1080aadbcac098d Mon Sep 17 00:00:00 2001
|
|
||||||
From: Ludovic Rousseau <ludovic.rousseau@free.fr>
|
|
||||||
Date: Fri, 1 Nov 2019 16:04:02 +0100
|
|
||||||
Subject: [PATCH 4/8] Linux backend: fix ressource leak
|
|
||||||
|
|
||||||
Issue detected by Coverity:
|
|
||||||
22. leaked_handle: Handle variable fd going out of scope leaks the handle.
|
|
||||||
|
|
||||||
Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
|
|
||||||
---
|
|
||||||
libusb/os/linux_usbfs.c | 4 ++++
|
|
||||||
1 file changed, 4 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
|
|
||||||
index 63fe592..dace935 100644
|
|
||||||
--- a/libusb/os/linux_usbfs.c
|
|
||||||
+++ b/libusb/os/linux_usbfs.c
|
|
||||||
@@ -1049,7 +1049,11 @@ static int initialize_device(struct libusb_device *dev, uint8_t busnum,
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sysfs_dir && sysfs_can_relate_devices)
|
|
||||||
+ {
|
|
||||||
+ if (fd != wrapped_fd)
|
|
||||||
+ close(fd);
|
|
||||||
return LIBUSB_SUCCESS;
|
|
||||||
+ }
|
|
||||||
|
|
||||||
/* cache active config */
|
|
||||||
if (wrapped_fd < 0)
|
|
||||||
--
|
|
||||||
2.27.0.windows.1
|
|
||||||
|
|
||||||
@ -1,119 +0,0 @@
|
|||||||
From ac43183a80de6350a681df218ed64e61fa5866b4 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
|
||||||
Date: Fri, 10 Jan 2020 20:04:52 +0100
|
|
||||||
Subject: [PATCH 5/8] core: fix build warning on newer versions of gcc
|
|
||||||
|
|
||||||
When building libusb on a "newer" version of gcc (9.2), a lot of
|
|
||||||
warnings are thrown about zero-length messages as being part of a format
|
|
||||||
string.
|
|
||||||
|
|
||||||
An example of this is:
|
|
||||||
|
|
||||||
descriptor.c:546:11: warning: zero-length gnu_printf format string [-Wformat-zero-length]
|
|
||||||
546 | usbi_dbg("");
|
|
||||||
| ^~
|
|
||||||
|
|
||||||
Fix this up by replacing all calls of:
|
|
||||||
usbi_dbg("");
|
|
||||||
with
|
|
||||||
usbi_dbg(" ");
|
|
||||||
as obviously we still want to keep the implicit tracing message in the
|
|
||||||
log.
|
|
||||||
|
|
||||||
Closes #674
|
|
||||||
|
|
||||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
|
||||||
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
||||||
---
|
|
||||||
libusb/core.c | 10 +++++-----
|
|
||||||
libusb/descriptor.c | 2 +-
|
|
||||||
libusb/io.c | 4 ++--
|
|
||||||
3 files changed, 8 insertions(+), 8 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/libusb/core.c b/libusb/core.c
|
|
||||||
index 741bf99..701d5af 100644
|
|
||||||
--- a/libusb/core.c
|
|
||||||
+++ b/libusb/core.c
|
|
||||||
@@ -812,7 +812,7 @@ ssize_t API_EXPORTED libusb_get_device_list(libusb_context *ctx,
|
|
||||||
int r = 0;
|
|
||||||
ssize_t i, len;
|
|
||||||
USBI_GET_CONTEXT(ctx);
|
|
||||||
- usbi_dbg("");
|
|
||||||
+ usbi_dbg(" ");
|
|
||||||
|
|
||||||
if (!discdevs)
|
|
||||||
return LIBUSB_ERROR_NO_MEM;
|
|
||||||
@@ -1492,7 +1492,7 @@ void API_EXPORTED libusb_close(libusb_device_handle *dev_handle)
|
|
||||||
|
|
||||||
if (!dev_handle)
|
|
||||||
return;
|
|
||||||
- usbi_dbg("");
|
|
||||||
+ usbi_dbg(" ");
|
|
||||||
|
|
||||||
ctx = HANDLE_CTX(dev_handle);
|
|
||||||
handling_events = usbi_handling_events(ctx);
|
|
||||||
@@ -1575,7 +1575,7 @@ int API_EXPORTED libusb_get_configuration(libusb_device_handle *dev_handle,
|
|
||||||
{
|
|
||||||
int r = LIBUSB_ERROR_NOT_SUPPORTED;
|
|
||||||
|
|
||||||
- usbi_dbg("");
|
|
||||||
+ usbi_dbg(" ");
|
|
||||||
if (usbi_backend.get_configuration)
|
|
||||||
r = usbi_backend.get_configuration(dev_handle, config);
|
|
||||||
|
|
||||||
@@ -1843,7 +1843,7 @@ int API_EXPORTED libusb_clear_halt(libusb_device_handle *dev_handle,
|
|
||||||
*/
|
|
||||||
int API_EXPORTED libusb_reset_device(libusb_device_handle *dev_handle)
|
|
||||||
{
|
|
||||||
- usbi_dbg("");
|
|
||||||
+ usbi_dbg(" ");
|
|
||||||
if (!dev_handle->dev->attached)
|
|
||||||
return LIBUSB_ERROR_NO_DEVICE;
|
|
||||||
|
|
||||||
@@ -2367,7 +2367,7 @@ void API_EXPORTED libusb_exit(struct libusb_context *ctx)
|
|
||||||
struct timeval tv = { 0, 0 };
|
|
||||||
int destroying_default_context = 0;
|
|
||||||
|
|
||||||
- usbi_dbg("");
|
|
||||||
+ usbi_dbg(" ");
|
|
||||||
USBI_GET_CONTEXT(ctx);
|
|
||||||
|
|
||||||
/* if working with default context, only actually do the deinitialization
|
|
||||||
diff --git a/libusb/descriptor.c b/libusb/descriptor.c
|
|
||||||
index 53905e6..53d1f6f 100644
|
|
||||||
--- a/libusb/descriptor.c
|
|
||||||
+++ b/libusb/descriptor.c
|
|
||||||
@@ -543,7 +543,7 @@ int usbi_device_cache_descriptor(libusb_device *dev)
|
|
||||||
int API_EXPORTED libusb_get_device_descriptor(libusb_device *dev,
|
|
||||||
struct libusb_device_descriptor *desc)
|
|
||||||
{
|
|
||||||
- usbi_dbg("");
|
|
||||||
+ usbi_dbg(" ");
|
|
||||||
memcpy((unsigned char *) desc, (unsigned char *) &dev->device_descriptor,
|
|
||||||
sizeof (dev->device_descriptor));
|
|
||||||
return 0;
|
|
||||||
diff --git a/libusb/io.c b/libusb/io.c
|
|
||||||
index 978b09a..77a048f 100644
|
|
||||||
--- a/libusb/io.c
|
|
||||||
+++ b/libusb/io.c
|
|
||||||
@@ -1330,7 +1330,7 @@ static int disarm_timerfd(struct libusb_context *ctx)
|
|
||||||
const struct itimerspec disarm_timer = { { 0, 0 }, { 0, 0 } };
|
|
||||||
int r;
|
|
||||||
|
|
||||||
- usbi_dbg("");
|
|
||||||
+ usbi_dbg(" ");
|
|
||||||
r = timerfd_settime(ctx->timerfd, 0, &disarm_timer, NULL);
|
|
||||||
if (r < 0)
|
|
||||||
return LIBUSB_ERROR_OTHER;
|
|
||||||
@@ -1912,7 +1912,7 @@ void API_EXPORTED libusb_interrupt_event_handler(libusb_context *ctx)
|
|
||||||
int pending_events;
|
|
||||||
USBI_GET_CONTEXT(ctx);
|
|
||||||
|
|
||||||
- usbi_dbg("");
|
|
||||||
+ usbi_dbg(" ");
|
|
||||||
usbi_mutex_lock(&ctx->event_data_lock);
|
|
||||||
|
|
||||||
pending_events = usbi_pending_events(ctx);
|
|
||||||
--
|
|
||||||
2.27.0.windows.1
|
|
||||||
|
|
||||||
@ -1,44 +0,0 @@
|
|||||||
From 4e97480722002927a993e9fa19d79f77df00a8f5 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
||||||
Date: Mon, 13 Jan 2020 14:07:31 -0800
|
|
||||||
Subject: [PATCH 6/8] core: Fix libusb_get_max_iso_packet_size() for superspeed
|
|
||||||
plus
|
|
||||||
|
|
||||||
The current logic fails to consider superspeed plus devices properly.
|
|
||||||
Fix this by checking for superspeed or greater instead of matching
|
|
||||||
against superspeed.
|
|
||||||
|
|
||||||
Closes #553
|
|
||||||
|
|
||||||
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
||||||
---
|
|
||||||
libusb/core.c | 6 +++---
|
|
||||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/libusb/core.c b/libusb/core.c
|
|
||||||
index 701d5af..82a5d03 100644
|
|
||||||
--- a/libusb/core.c
|
|
||||||
+++ b/libusb/core.c
|
|
||||||
@@ -1120,8 +1120,8 @@ int API_EXPORTED libusb_get_max_iso_packet_size(libusb_device *dev,
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
- speed = libusb_get_device_speed( dev );
|
|
||||||
- if (speed == LIBUSB_SPEED_SUPER) {
|
|
||||||
+ speed = libusb_get_device_speed(dev);
|
|
||||||
+ if (speed >= LIBUSB_SPEED_SUPER) {
|
|
||||||
r = libusb_get_ss_endpoint_companion_descriptor(dev->ctx, ep, &ss_ep_cmp);
|
|
||||||
if (r == LIBUSB_SUCCESS) {
|
|
||||||
r = ss_ep_cmp->wBytesPerInterval;
|
|
||||||
@@ -1130,7 +1130,7 @@ int API_EXPORTED libusb_get_max_iso_packet_size(libusb_device *dev,
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If the device isn't a SuperSpeed device or retrieving the SS endpoint didn't worked. */
|
|
||||||
- if (speed != LIBUSB_SPEED_SUPER || r < 0) {
|
|
||||||
+ if (speed < LIBUSB_SPEED_SUPER || r < 0) {
|
|
||||||
val = ep->wMaxPacketSize;
|
|
||||||
ep_type = (enum libusb_transfer_type) (ep->bmAttributes & 0x3);
|
|
||||||
|
|
||||||
--
|
|
||||||
2.27.0.windows.1
|
|
||||||
|
|
||||||
@ -1,71 +0,0 @@
|
|||||||
From d7f8d239cb49775a1fe7765d6edb463d7fe669e1 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
||||||
Date: Mon, 13 Jan 2020 15:05:00 -0800
|
|
||||||
Subject: [PATCH 7/8] core: Do not attempt to destroy a default context that
|
|
||||||
doesn't exist
|
|
||||||
|
|
||||||
Calling libusb_exit(NULL) when a successful call to libusb_init(NULL)
|
|
||||||
has not been made results in a segmentation violation. This is
|
|
||||||
definitely a user error, but we can easily guard against it.
|
|
||||||
|
|
||||||
Closes #511
|
|
||||||
|
|
||||||
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
||||||
---
|
|
||||||
libusb/core.c | 16 +++++++++++-----
|
|
||||||
1 file changed, 11 insertions(+), 5 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/libusb/core.c b/libusb/core.c
|
|
||||||
index 82a5d03..3b6a265 100644
|
|
||||||
--- a/libusb/core.c
|
|
||||||
+++ b/libusb/core.c
|
|
||||||
@@ -2304,7 +2304,7 @@ int API_EXPORTED libusb_init(libusb_context **context)
|
|
||||||
usbi_mutex_static_lock(&active_contexts_lock);
|
|
||||||
if (first_init) {
|
|
||||||
first_init = 0;
|
|
||||||
- list_init (&active_contexts_list);
|
|
||||||
+ list_init(&active_contexts_list);
|
|
||||||
}
|
|
||||||
list_add (&ctx->list, &active_contexts_list);
|
|
||||||
usbi_mutex_static_unlock(&active_contexts_lock);
|
|
||||||
@@ -2336,7 +2336,7 @@ err_free_ctx:
|
|
||||||
}
|
|
||||||
|
|
||||||
usbi_mutex_static_lock(&active_contexts_lock);
|
|
||||||
- list_del (&ctx->list);
|
|
||||||
+ list_del(&ctx->list);
|
|
||||||
usbi_mutex_static_unlock(&active_contexts_lock);
|
|
||||||
|
|
||||||
usbi_mutex_lock(&ctx->usb_devs_lock);
|
|
||||||
@@ -2374,6 +2374,12 @@ void API_EXPORTED libusb_exit(struct libusb_context *ctx)
|
|
||||||
* if we're the last user */
|
|
||||||
usbi_mutex_static_lock(&default_context_lock);
|
|
||||||
if (ctx == usbi_default_context) {
|
|
||||||
+ if (!usbi_default_context) {
|
|
||||||
+ usbi_dbg("no default context, not initialized?");
|
|
||||||
+ usbi_mutex_static_unlock(&default_context_lock);
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
if (--default_context_refcnt > 0) {
|
|
||||||
usbi_dbg("not destroying default context");
|
|
||||||
usbi_mutex_static_unlock(&default_context_lock);
|
|
||||||
@@ -2389,12 +2395,12 @@ void API_EXPORTED libusb_exit(struct libusb_context *ctx)
|
|
||||||
*/
|
|
||||||
destroying_default_context = 1;
|
|
||||||
} else {
|
|
||||||
- // Unlock default context, as we're not modifying it.
|
|
||||||
+ /* Unlock default context, as we're not modifying it. */
|
|
||||||
usbi_mutex_static_unlock(&default_context_lock);
|
|
||||||
- }
|
|
||||||
+ }
|
|
||||||
|
|
||||||
usbi_mutex_static_lock(&active_contexts_lock);
|
|
||||||
- list_del (&ctx->list);
|
|
||||||
+ list_del(&ctx->list);
|
|
||||||
usbi_mutex_static_unlock(&active_contexts_lock);
|
|
||||||
|
|
||||||
if (libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) {
|
|
||||||
--
|
|
||||||
2.27.0.windows.1
|
|
||||||
|
|
||||||
@ -1,246 +0,0 @@
|
|||||||
From 3e55f94b6728fcabf35bcac74d6658fbaee0325f Mon Sep 17 00:00:00 2001
|
|
||||||
From: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
||||||
Date: Thu, 16 Jan 2020 14:17:12 -0800
|
|
||||||
Subject: [PATCH 8/8] linux_usbfs: Wait until all URBs have been reaped before
|
|
||||||
freeing them
|
|
||||||
|
|
||||||
Prior to this change, the URBs allocated for an individual transfer were
|
|
||||||
freed when the last URB in the transfer was reaped. Normally this causes
|
|
||||||
no issues because URBs are reaped in the order they were submitted. If
|
|
||||||
the device is disconnected while multiple URBs are queued, these URBs
|
|
||||||
may be reaped in an order that does not match that of submission.
|
|
||||||
|
|
||||||
Change the logic to free the URBs when all the URBs of a transfer have
|
|
||||||
been reaped rather than the last one. While in here, improve some debug
|
|
||||||
messages.
|
|
||||||
|
|
||||||
Closes #607
|
|
||||||
|
|
||||||
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
||||||
---
|
|
||||||
libusb/os/linux_usbfs.c | 58 ++++++++++++++++++++---------------------
|
|
||||||
1 file changed, 29 insertions(+), 29 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
|
|
||||||
index dace935..6c89226 100644
|
|
||||||
--- a/libusb/os/linux_usbfs.c
|
|
||||||
+++ b/libusb/os/linux_usbfs.c
|
|
||||||
@@ -944,7 +944,7 @@ static int usbfs_get_active_config(struct libusb_device *dev, int fd)
|
|
||||||
|
|
||||||
/* we hit this error path frequently with buggy devices :( */
|
|
||||||
usbi_warn(DEVICE_CTX(dev),
|
|
||||||
- "get_configuration failed ret=%d errno=%d", r, errno);
|
|
||||||
+ "get configuration failed, errno=%d", errno);
|
|
||||||
priv->active_config = -1;
|
|
||||||
} else {
|
|
||||||
if (active_config > 0) {
|
|
||||||
@@ -1401,7 +1401,7 @@ static int initialize_handle(struct libusb_device_handle *handle, int fd)
|
|
||||||
if (errno == ENOTTY)
|
|
||||||
usbi_dbg("getcap not available");
|
|
||||||
else
|
|
||||||
- usbi_err(HANDLE_CTX(handle), "getcap failed (%d)", errno);
|
|
||||||
+ usbi_err(HANDLE_CTX(handle), "getcap failed, errno=%d", errno);
|
|
||||||
hpriv->caps = 0;
|
|
||||||
if (supports_flag_zero_packet)
|
|
||||||
hpriv->caps |= USBFS_CAP_ZERO_PACKET;
|
|
||||||
@@ -1426,7 +1426,7 @@ static int op_wrap_sys_device(struct libusb_context *ctx,
|
|
||||||
if (r < 0) {
|
|
||||||
r = ioctl(fd, IOCTL_USBFS_CONNECTINFO, &ci);
|
|
||||||
if (r < 0) {
|
|
||||||
- usbi_err(ctx, "connectinfo failed (%d)", errno);
|
|
||||||
+ usbi_err(ctx, "connectinfo failed, errno=%d", errno);
|
|
||||||
return LIBUSB_ERROR_IO;
|
|
||||||
}
|
|
||||||
/* There is no ioctl to get the bus number. We choose 0 here
|
|
||||||
@@ -1537,7 +1537,8 @@ static int op_set_configuration(struct libusb_device_handle *handle, int config)
|
|
||||||
else if (errno == ENODEV)
|
|
||||||
return LIBUSB_ERROR_NO_DEVICE;
|
|
||||||
|
|
||||||
- usbi_err(HANDLE_CTX(handle), "failed, error %d errno %d", r, errno);
|
|
||||||
+ usbi_err(HANDLE_CTX(handle),
|
|
||||||
+ "set configuration failed, errno=%d", errno);
|
|
||||||
return LIBUSB_ERROR_OTHER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1560,7 +1561,7 @@ static int claim_interface(struct libusb_device_handle *handle, int iface)
|
|
||||||
return LIBUSB_ERROR_NO_DEVICE;
|
|
||||||
|
|
||||||
usbi_err(HANDLE_CTX(handle),
|
|
||||||
- "claim interface failed, error %d errno %d", r, errno);
|
|
||||||
+ "claim interface failed, errno=%d", errno);
|
|
||||||
return LIBUSB_ERROR_OTHER;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
@@ -1575,7 +1576,7 @@ static int release_interface(struct libusb_device_handle *handle, int iface)
|
|
||||||
return LIBUSB_ERROR_NO_DEVICE;
|
|
||||||
|
|
||||||
usbi_err(HANDLE_CTX(handle),
|
|
||||||
- "release interface failed, error %d errno %d", r, errno);
|
|
||||||
+ "release interface failed, errno=%d", errno);
|
|
||||||
return LIBUSB_ERROR_OTHER;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
@@ -1598,7 +1599,7 @@ static int op_set_interface(struct libusb_device_handle *handle, int iface,
|
|
||||||
return LIBUSB_ERROR_NO_DEVICE;
|
|
||||||
|
|
||||||
usbi_err(HANDLE_CTX(handle),
|
|
||||||
- "setintf failed error %d errno %d", r, errno);
|
|
||||||
+ "set interface failed, errno=%d", errno);
|
|
||||||
return LIBUSB_ERROR_OTHER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1618,7 +1619,7 @@ static int op_clear_halt(struct libusb_device_handle *handle,
|
|
||||||
return LIBUSB_ERROR_NO_DEVICE;
|
|
||||||
|
|
||||||
usbi_err(HANDLE_CTX(handle),
|
|
||||||
- "clear_halt failed error %d errno %d", r, errno);
|
|
||||||
+ "clear halt failed, errno=%d", errno);
|
|
||||||
return LIBUSB_ERROR_OTHER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1650,7 +1651,7 @@ static int op_reset_device(struct libusb_device_handle *handle)
|
|
||||||
}
|
|
||||||
|
|
||||||
usbi_err(HANDLE_CTX(handle),
|
|
||||||
- "reset failed error %d errno %d", r, errno);
|
|
||||||
+ "reset failed, errno=%d", errno);
|
|
||||||
ret = LIBUSB_ERROR_OTHER;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
@@ -1708,7 +1709,7 @@ static int do_streams_ioctl(struct libusb_device_handle *handle, long req,
|
|
||||||
return LIBUSB_ERROR_NO_DEVICE;
|
|
||||||
|
|
||||||
usbi_err(HANDLE_CTX(handle),
|
|
||||||
- "streams-ioctl failed error %d errno %d", r, errno);
|
|
||||||
+ "streams-ioctl failed, errno=%d", errno);
|
|
||||||
return LIBUSB_ERROR_OTHER;
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
@@ -1770,7 +1771,7 @@ static int op_kernel_driver_active(struct libusb_device_handle *handle,
|
|
||||||
return LIBUSB_ERROR_NO_DEVICE;
|
|
||||||
|
|
||||||
usbi_err(HANDLE_CTX(handle),
|
|
||||||
- "get driver failed error %d errno %d", r, errno);
|
|
||||||
+ "get driver failed, errno=%d", errno);
|
|
||||||
return LIBUSB_ERROR_OTHER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1804,7 +1805,7 @@ static int op_detach_kernel_driver(struct libusb_device_handle *handle,
|
|
||||||
return LIBUSB_ERROR_NO_DEVICE;
|
|
||||||
|
|
||||||
usbi_err(HANDLE_CTX(handle),
|
|
||||||
- "detach failed error %d errno %d", r, errno);
|
|
||||||
+ "detach failed, errno=%d", errno);
|
|
||||||
return LIBUSB_ERROR_OTHER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1834,7 +1835,7 @@ static int op_attach_kernel_driver(struct libusb_device_handle *handle,
|
|
||||||
return LIBUSB_ERROR_BUSY;
|
|
||||||
|
|
||||||
usbi_err(HANDLE_CTX(handle),
|
|
||||||
- "attach failed error %d errno %d", r, errno);
|
|
||||||
+ "attach failed, errno=%d", errno);
|
|
||||||
return LIBUSB_ERROR_OTHER;
|
|
||||||
} else if (r == 0) {
|
|
||||||
return LIBUSB_ERROR_NOT_FOUND;
|
|
||||||
@@ -1863,7 +1864,7 @@ static int detach_kernel_driver_and_claim(struct libusb_device_handle *handle,
|
|
||||||
return LIBUSB_ERROR_NO_DEVICE;
|
|
||||||
}
|
|
||||||
usbi_err(HANDLE_CTX(handle),
|
|
||||||
- "disconnect-and-claim failed errno %d", errno);
|
|
||||||
+ "disconnect-and-claim failed, errno=%d", errno);
|
|
||||||
return LIBUSB_ERROR_OTHER;
|
|
||||||
} else if (r == 0)
|
|
||||||
return 0;
|
|
||||||
@@ -2239,7 +2240,7 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer)
|
|
||||||
r = LIBUSB_ERROR_INVALID_PARAM;
|
|
||||||
} else {
|
|
||||||
usbi_err(TRANSFER_CTX(transfer),
|
|
||||||
- "submiturb failed error %d errno=%d", r, errno);
|
|
||||||
+ "submiturb failed, errno=%d", errno);
|
|
||||||
r = LIBUSB_ERROR_IO;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -2314,7 +2315,7 @@ static int submit_control_transfer(struct usbi_transfer *itransfer)
|
|
||||||
return LIBUSB_ERROR_NO_DEVICE;
|
|
||||||
|
|
||||||
usbi_err(TRANSFER_CTX(transfer),
|
|
||||||
- "submiturb failed error %d errno=%d", r, errno);
|
|
||||||
+ "submiturb failed, errno=%d", errno);
|
|
||||||
return LIBUSB_ERROR_IO;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
@@ -2496,10 +2497,10 @@ static int handle_bulk_completion(struct usbi_transfer *itransfer,
|
|
||||||
goto cancel_remaining;
|
|
||||||
}
|
|
||||||
|
|
||||||
- /* if we're the last urb or we got less data than requested then we're
|
|
||||||
+ /* if we've reaped all urbs or we got less data than requested then we're
|
|
||||||
* done */
|
|
||||||
- if (urb_idx == tpriv->num_urbs - 1) {
|
|
||||||
- usbi_dbg("last URB in transfer --> complete!");
|
|
||||||
+ if (tpriv->num_retired == tpriv->num_urbs) {
|
|
||||||
+ usbi_dbg("all URBs in transfer reaped --> complete!");
|
|
||||||
goto completed;
|
|
||||||
} else if (urb->actual_length < urb->buffer_length) {
|
|
||||||
usbi_dbg("short transfer %d/%d --> complete!",
|
|
||||||
@@ -2575,15 +2576,15 @@ static int handle_iso_completion(struct usbi_transfer *itransfer,
|
|
||||||
break;
|
|
||||||
case -ENODEV:
|
|
||||||
case -ESHUTDOWN:
|
|
||||||
- usbi_dbg("device removed");
|
|
||||||
+ usbi_dbg("packet %d - device removed", i);
|
|
||||||
lib_desc->status = LIBUSB_TRANSFER_NO_DEVICE;
|
|
||||||
break;
|
|
||||||
case -EPIPE:
|
|
||||||
- usbi_dbg("detected endpoint stall");
|
|
||||||
+ usbi_dbg("packet %d - detected endpoint stall", i);
|
|
||||||
lib_desc->status = LIBUSB_TRANSFER_STALL;
|
|
||||||
break;
|
|
||||||
case -EOVERFLOW:
|
|
||||||
- usbi_dbg("overflow error");
|
|
||||||
+ usbi_dbg("packet %d - overflow error", i);
|
|
||||||
lib_desc->status = LIBUSB_TRANSFER_OVERFLOW;
|
|
||||||
break;
|
|
||||||
case -ETIME:
|
|
||||||
@@ -2592,12 +2593,12 @@ static int handle_iso_completion(struct usbi_transfer *itransfer,
|
|
||||||
case -ECOMM:
|
|
||||||
case -ENOSR:
|
|
||||||
case -EXDEV:
|
|
||||||
- usbi_dbg("low-level USB error %d", urb_desc->status);
|
|
||||||
+ usbi_dbg("packet %d - low-level USB error %d", i, urb_desc->status);
|
|
||||||
lib_desc->status = LIBUSB_TRANSFER_ERROR;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
usbi_warn(TRANSFER_CTX(transfer),
|
|
||||||
- "unrecognised urb status %d", urb_desc->status);
|
|
||||||
+ "packet %d - unrecognised urb status %d", i, urb_desc->status);
|
|
||||||
lib_desc->status = LIBUSB_TRANSFER_ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
@@ -2641,9 +2642,9 @@ static int handle_iso_completion(struct usbi_transfer *itransfer,
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
- /* if we're the last urb then we're done */
|
|
||||||
- if (urb_idx == num_urbs) {
|
|
||||||
- usbi_dbg("last URB in transfer --> complete!");
|
|
||||||
+ /* if we've reaped all urbs then we're done */
|
|
||||||
+ if (tpriv->num_retired == num_urbs) {
|
|
||||||
+ usbi_dbg("all URBs in transfer reaped --> complete!");
|
|
||||||
free_iso_urbs(tpriv);
|
|
||||||
usbi_mutex_unlock(&itransfer->lock);
|
|
||||||
return usbi_handle_transfer_completion(itransfer, status);
|
|
||||||
@@ -2731,8 +2732,7 @@ static int reap_for_handle(struct libusb_device_handle *handle)
|
|
||||||
if (errno == ENODEV)
|
|
||||||
return LIBUSB_ERROR_NO_DEVICE;
|
|
||||||
|
|
||||||
- usbi_err(HANDLE_CTX(handle), "reap failed error %d errno=%d",
|
|
||||||
- r, errno);
|
|
||||||
+ usbi_err(HANDLE_CTX(handle), "reap failed, errno=%d", errno);
|
|
||||||
return LIBUSB_ERROR_IO;
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
2.27.0.windows.1
|
|
||||||
|
|
||||||
Binary file not shown.
BIN
libusb-1.0.24.tar.bz2
Normal file
BIN
libusb-1.0.24.tar.bz2
Normal file
Binary file not shown.
20
libusbx.spec
20
libusbx.spec
@ -2,21 +2,12 @@
|
|||||||
%global source libusb
|
%global source libusb
|
||||||
|
|
||||||
Name: libusbx
|
Name: libusbx
|
||||||
Version: 1.0.23
|
Version: 1.0.24
|
||||||
Release: 4
|
Release: 1
|
||||||
Summary: Library for accessing USB devices
|
Summary: Library for accessing USB devices
|
||||||
License: LGPLv2+
|
License: LGPLv2+
|
||||||
URL: http://libusb.info
|
URL: http://libusb.info
|
||||||
Source0: https://github.com/libusb/libusb/releases/download/v1.0.23/libusb-1.0.23.tar.bz2
|
Source0: https://github.com/libusb/libusb/releases/download/v1.0.24/libusb-1.0.24.tar.bz2
|
||||||
|
|
||||||
Patch1: 0001-fix-constant-not-in-range-of-enumerated-type.patch
|
|
||||||
Patch2: 0002-Solaris-backend-is-not-correctly-setting-the-one-tra.patch
|
|
||||||
Patch3: 0003-Solaris-fails-to-find-USB-devices-on-SPARC-platform.patch
|
|
||||||
Patch4: 0004-Linux-backend-fix-ressource-leak.patch
|
|
||||||
Patch5: 0005-core-fix-build-warning-on-newer-versions-of-gcc.patch
|
|
||||||
Patch6: 0006-core-Fix-libusb_get_max_iso_packet_size-for-superspe.patch
|
|
||||||
Patch7: 0007-core-Do-not-attempt-to-destroy-a-default-context-tha.patch
|
|
||||||
Patch8: 0008-linux_usbfs-Wait-until-all-URBs-have-been-reaped-bef.patch
|
|
||||||
|
|
||||||
BuildRequires: systemd-devel doxygen libtool
|
BuildRequires: systemd-devel doxygen libtool
|
||||||
|
|
||||||
@ -63,12 +54,15 @@ make check
|
|||||||
%exclude %{_libdir}/*.la
|
%exclude %{_libdir}/*.la
|
||||||
|
|
||||||
%files devel
|
%files devel
|
||||||
%doc doc/html examples/*.c
|
%doc examples/*.c
|
||||||
%{_includedir}/libusb-1.0
|
%{_includedir}/libusb-1.0
|
||||||
%{_libdir}/*.so
|
%{_libdir}/*.so
|
||||||
%{_libdir}/pkgconfig/libusb-1.0.pc
|
%{_libdir}/pkgconfig/libusb-1.0.pc
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Nov 17 2021 Wenchao Hao <haowenchao@hauwei.com> - 1.0.24-1
|
||||||
|
- Update to libusb-1.0.24
|
||||||
|
|
||||||
* Fri Jul 23 2021 zhouwenpei <zhouwenpei1@hauwei.com> - 1.0.23-4
|
* Fri Jul 23 2021 zhouwenpei <zhouwenpei1@hauwei.com> - 1.0.23-4
|
||||||
- remove unnecessary build require.
|
- remove unnecessary build require.
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user