aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--METADATA4
-rw-r--r--examples/xusb.c25
-rw-r--r--libusb/core.c2
-rw-r--r--libusb/descriptor.c27
-rw-r--r--libusb/io.c4
-rw-r--r--libusb/libusb.h4
-rw-r--r--libusb/os/darwin_usb.c2
-rw-r--r--libusb/os/events_posix.c8
-rw-r--r--libusb/os/linux_usbfs.c13
-rw-r--r--libusb/os/sunos_usb.c2
-rw-r--r--libusb/os/windows_winusb.c2
-rw-r--r--libusb/version_nano.h2
12 files changed, 49 insertions, 46 deletions
diff --git a/METADATA b/METADATA
index bcf5c95..6db0d54 100644
--- a/METADATA
+++ b/METADATA
@@ -9,12 +9,12 @@ third_party {
last_upgrade_date {
year: 2024
month: 5
- day: 21
+ day: 28
}
homepage: "https://libusb.info/"
identifier {
type: "Git"
value: "https://github.com/libusb/libusb"
- version: "fef78a96e37936f16c10c43c9a220683f7c2ff74"
+ version: "2a138c6f12988c42eaa9dd663581faa700c44abe"
}
}
diff --git a/examples/xusb.c b/examples/xusb.c
index 83e5525..1ee4639 100644
--- a/examples/xusb.c
+++ b/examples/xusb.c
@@ -770,11 +770,11 @@ static void print_sublink_speed_attribute(struct libusb_ssplus_sublink_attribute
static const char exponent[] = " KMG";
printf(" id=%u speed=%u%cbs %s %s SuperSpeed%s",
ss_attr->ssid,
- ss_attr->mantisa,
+ ss_attr->mantissa,
(exponent[ss_attr->exponent]),
(ss_attr->type == LIBUSB_SSPLUS_ATTR_TYPE_ASYM)? "Asym" : "Sym",
(ss_attr->direction == LIBUSB_SSPLUS_ATTR_DIR_TX)? "TX" : "RX",
- (ss_attr->protocol == LIBUSB_SSPLUS_ATTR_PROT_SSPLUS)? "+": "" );
+ (ss_attr->protocol == LIBUSB_SSPLUS_ATTR_PROT_SSPLUS)? "Plus": "" );
}
static void print_device_cap(struct libusb_bos_dev_capability_descriptor *dev_cap)
@@ -854,7 +854,6 @@ static int test_device(uint16_t vid, uint16_t pid)
libusb_device_handle *handle;
libusb_device *dev;
uint8_t bus, port_path[8];
- struct libusb_bos_descriptor *bos_desc;
struct libusb_config_descriptor *conf_desc;
const struct libusb_endpoint_descriptor *endpoint;
int i, j, k, r;
@@ -908,14 +907,18 @@ static int test_device(uint16_t vid, uint16_t pid)
string_index[1] = dev_desc.iProduct;
string_index[2] = dev_desc.iSerialNumber;
- printf("\nReading BOS descriptor: ");
- if (libusb_get_bos_descriptor(handle, &bos_desc) == LIBUSB_SUCCESS) {
- printf("%d caps\n", bos_desc->bNumDeviceCaps);
- for (i = 0; i < bos_desc->bNumDeviceCaps; i++)
- print_device_cap(bos_desc->dev_capability[i]);
- libusb_free_bos_descriptor(bos_desc);
- } else {
- printf("no descriptor\n");
+ if (dev_desc.bcdUSB >= 0x0201) {
+ struct libusb_bos_descriptor *bos_desc;
+
+ printf("\nReading BOS descriptor: ");
+ if (libusb_get_bos_descriptor(handle, &bos_desc) == LIBUSB_SUCCESS) {
+ printf("%d caps\n", bos_desc->bNumDeviceCaps);
+ for (i = 0; i < bos_desc->bNumDeviceCaps; i++)
+ print_device_cap(bos_desc->dev_capability[i]);
+ libusb_free_bos_descriptor(bos_desc);
+ } else {
+ printf("no descriptor\n");
+ }
}
printf("\nReading first configuration descriptor:\n");
diff --git a/libusb/core.c b/libusb/core.c
index 010201c..7461737 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -954,7 +954,7 @@ int API_EXPORTED libusb_get_port_numbers(libusb_device *dev,
if (port_numbers_len <= 0)
return LIBUSB_ERROR_INVALID_PARAM;
- // HCDs can be listed as devices with port #0
+ /* HCDs can be listed as devices with port #0 */
while((dev) && (dev->port_number != 0)) {
if (--i < 0) {
usbi_warn(ctx, "port numbers array is too small");
diff --git a/libusb/descriptor.c b/libusb/descriptor.c
index b72f558..493507f 100644
--- a/libusb/descriptor.c
+++ b/libusb/descriptor.c
@@ -1006,9 +1006,9 @@ int API_EXPORTED libusb_get_ss_usb_device_capability_descriptor(
return LIBUSB_SUCCESS;
}
-// We use this private struct ony to parse a superspeed+ device capability
-// descriptor according to section 9.6.2.5 of the USB 3.1 specification.
-// We don't expose it.
+/* We use this private struct only to parse a SuperSpeedPlus device capability
+ descriptor according to section 9.6.2.5 of the USB 3.1 specification.
+ We don't expose it. */
struct internal_ssplus_capability_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
@@ -1026,10 +1026,10 @@ int API_EXPORTED libusb_get_ssplus_usb_device_capability_descriptor(
{
struct libusb_ssplus_usb_device_capability_descriptor *_ssplus_cap;
- // Use a private struct to re-use our descriptor parsing system.
+ /* Use a private struct to reuse our descriptor parsing system. */
struct internal_ssplus_capability_descriptor parsedDescriptor;
- // Some size/type checks to make sure everything is in order
+ /* Some size/type checks to make sure everything is in order */
if (dev_cap->bDevCapabilityType != LIBUSB_BT_SUPERSPEED_PLUS_CAPABILITY) {
usbi_err(ctx, "unexpected bDevCapabilityType 0x%x (expected 0x%x)",
dev_cap->bDevCapabilityType,
@@ -1041,8 +1041,7 @@ int API_EXPORTED libusb_get_ssplus_usb_device_capability_descriptor(
return LIBUSB_ERROR_IO;
}
- // We can only parse the non-variable size part of the SuperSpeedPlus descriptor. The attributes
- // have to be read "manually".
+ /* We can only parse the non-variable size part of the SuperSpeedPlus descriptor. The attributes have to be read "manually". */
parse_descriptor(dev_cap, "bbbbiww", &parsedDescriptor);
uint8_t numSublikSpeedAttributes = (parsedDescriptor.bmAttributes & 0xF) + 1;
@@ -1050,27 +1049,27 @@ int API_EXPORTED libusb_get_ssplus_usb_device_capability_descriptor(
if (!_ssplus_cap)
return LIBUSB_ERROR_NO_MEM;
- // Parse bmAttributes
+ /* Parse bmAttributes */
_ssplus_cap->numSublinkSpeedAttributes = numSublikSpeedAttributes;
_ssplus_cap->numSublinkSpeedIDs = ((parsedDescriptor.bmAttributes & 0xF0) >> 4) + 1;
- // Parse wFunctionalitySupport
+ /* Parse wFunctionalitySupport */
_ssplus_cap->ssid = parsedDescriptor.wFunctionalitySupport & 0xF;
_ssplus_cap->minRxLaneCount = (parsedDescriptor.wFunctionalitySupport & 0x0F00) >> 8;
_ssplus_cap->minTxLaneCount = (parsedDescriptor.wFunctionalitySupport & 0xF000) >> 12;
- // Check that we have enough to read all the sublink attributes
+ /* Check that we have enough to read all the sublink attributes */
if (dev_cap->bLength < LIBUSB_BT_SSPLUS_USB_DEVICE_CAPABILITY_SIZE + _ssplus_cap->numSublinkSpeedAttributes * sizeof(uint32_t)) {
usbi_err(ctx, "short ssplus capability descriptor, unable to read sublinks: Not enough data");
return LIBUSB_ERROR_IO;
}
- // Read the attributes
+ /* Read the attributes */
uint8_t* base = ((uint8_t*)dev_cap) + LIBUSB_BT_SSPLUS_USB_DEVICE_CAPABILITY_SIZE;
for(uint8_t i = 0 ; i < _ssplus_cap->numSublinkSpeedAttributes ; i++) {
uint32_t attr = READ_LE32(base + i * sizeof(uint32_t));
_ssplus_cap->sublinkSpeedAttributes[i].ssid = attr & 0x0f;
- _ssplus_cap->sublinkSpeedAttributes[i].mantisa = attr >> 16;
+ _ssplus_cap->sublinkSpeedAttributes[i].mantissa = attr >> 16;
_ssplus_cap->sublinkSpeedAttributes[i].exponent = (attr >> 4) & 0x3 ;
_ssplus_cap->sublinkSpeedAttributes[i].type = attr & 0x40 ? LIBUSB_SSPLUS_ATTR_TYPE_ASYM : LIBUSB_SSPLUS_ATTR_TYPE_SYM;
_ssplus_cap->sublinkSpeedAttributes[i].direction = attr & 0x80 ? LIBUSB_SSPLUS_ATTR_DIR_TX : LIBUSB_SSPLUS_ATTR_DIR_RX;
@@ -1312,7 +1311,7 @@ static int parse_iad_array(struct libusb_context *ctx,
return LIBUSB_ERROR_IO;
}
- // First pass: Iterate through desc list, count number of IADs
+ /* First pass: Iterate through desc list, count number of IADs */
iad_array->length = 0;
while (consumed < size) {
parse_descriptor(buf, "bb", &header);
@@ -1335,7 +1334,7 @@ static int parse_iad_array(struct libusb_context *ctx,
iad_array->iad = iad;
- // Second pass: Iterate through desc list, fill IAD structures
+ /* Second pass: Iterate through desc list, fill IAD structures */
consumed = 0;
i = 0;
while (consumed < size) {
diff --git a/libusb/io.c b/libusb/io.c
index 0b2aaf6..fa26ffa 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -2045,7 +2045,7 @@ int API_EXPORTED libusb_wait_for_event(libusb_context *ctx, struct timeval *tv)
return 0;
}
-// NB: flying_transfers_lock must be held when calling this
+/* NB: flying_transfers_lock must be held when calling this */
static void handle_timeout(struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer =
@@ -2061,7 +2061,7 @@ static void handle_timeout(struct usbi_transfer *itransfer)
"async cancel failed %d", r);
}
-// NB: flying_transfers_lock must be held when calling this
+/* NB: flying_transfers_lock must be held when calling this */
static void handle_timeouts_locked(struct libusb_context *ctx)
{
struct timespec systime;
diff --git a/libusb/libusb.h b/libusb/libusb.h
index 2353f4c..fa1ca6b 100644
--- a/libusb/libusb.h
+++ b/libusb/libusb.h
@@ -565,7 +565,7 @@ enum libusb_bos_type {
/** Platform descriptor */
LIBUSB_BT_PLATFORM_DESCRIPTOR = 0x05,
- /* SuperSpeed+ device capability */
+ /* SuperSpeedPlus device capability */
LIBUSB_BT_SUPERSPEED_PLUS_CAPABILITY = 0x0A,
};
@@ -1051,7 +1051,7 @@ struct libusb_ssplus_sublink_attribute {
/** This field defines the mantissa that shall be applied to the exponent when
calculating the maximum bit rate. */
- uint16_t mantisa;
+ uint16_t mantissa;
};
/** \ingroup libusb_desc
diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c
index ae09db7..7bb496b 100644
--- a/libusb/os/darwin_usb.c
+++ b/libusb/os/darwin_usb.c
@@ -1092,7 +1092,7 @@ static IOReturn darwin_request_descriptor (usb_device_t device, UInt8 desc, UInt
static enum libusb_error darwin_cache_device_descriptor (struct libusb_context *ctx, struct darwin_cached_device *dev) {
usb_device_t device = dev->device;
int retries = 1;
- long delay = 30000; // microseconds
+ long delay = 30000; /* microseconds */
int unsuspended = 0, try_unsuspend = 1, try_reconfigure = 1;
int is_open = 0;
IOReturn ret = 0, ret2;
diff --git a/libusb/os/events_posix.c b/libusb/os/events_posix.c
index 4056dae..bf984b9 100644
--- a/libusb/os/events_posix.c
+++ b/libusb/os/events_posix.c
@@ -256,11 +256,11 @@ int usbi_wait_for_events(struct libusb_context *ctx,
usbi_dbg(ctx, "poll() %u fds with timeout in %dms", (unsigned int)nfds, timeout_ms);
#ifdef __EMSCRIPTEN__
- // Emscripten's poll doesn't actually block, so we need to use an out-of-band
- // waiting signal.
+ /* Emscripten's poll doesn't actually block, so we need to use an
+ * out-of-band waiting signal. */
em_libusb_wait(&ctx->event.has_event, 0, timeout_ms);
- // Emscripten ignores timeout_ms, but set it to 0 for future-proofing in case
- // they ever implement real poll.
+ /* Emscripten ignores timeout_ms, but set it to 0 for future-proofing
+ * in case they ever implement real poll. */
timeout_ms = 0;
#endif
num_ready = poll(fds, nfds, timeout_ms);
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
index 25ee02e..8c7b3a9 100644
--- a/libusb/os/linux_usbfs.c
+++ b/libusb/os/linux_usbfs.c
@@ -182,7 +182,7 @@ static int dev_has_config0(struct libusb_device *dev)
return 0;
}
-static int get_usbfs_fd(struct libusb_device *dev, mode_t mode, int silent)
+static int get_usbfs_fd(struct libusb_device *dev, int access_mode, int silent)
{
struct libusb_context *ctx = DEVICE_CTX(dev);
char path[24];
@@ -195,7 +195,7 @@ static int get_usbfs_fd(struct libusb_device *dev, mode_t mode, int silent)
snprintf(path, sizeof(path), USB_DEVTMPFS_PATH "/%03u/%03u",
dev->bus_number, dev->device_address);
- fd = open(path, mode | O_CLOEXEC);
+ fd = open(path, access_mode | O_CLOEXEC);
if (fd != -1)
return fd; /* Success */
@@ -209,14 +209,14 @@ static int get_usbfs_fd(struct libusb_device *dev, mode_t mode, int silent)
/* Wait 10ms for USB device path creation.*/
nanosleep(&delay_ts, NULL);
- fd = open(path, mode | O_CLOEXEC);
+ fd = open(path, access_mode | O_CLOEXEC);
if (fd != -1)
return fd; /* Success */
}
if (!silent) {
usbi_err(ctx, "libusb couldn't open USB device %s, errno=%d", path, errno);
- if (errno == EACCES && mode == O_RDWR)
+ if (errno == EACCES && access_mode == O_RDWR)
usbi_err(ctx, "libusb requires write access to USB device nodes");
}
@@ -1628,8 +1628,9 @@ out:
return ret;
}
-static int do_streams_ioctl(struct libusb_device_handle *handle, long req,
- uint32_t num_streams, unsigned char *endpoints, int num_endpoints)
+static int do_streams_ioctl(struct libusb_device_handle *handle,
+ unsigned long req, uint32_t num_streams, unsigned char *endpoints,
+ int num_endpoints)
{
struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
int r, fd = hpriv->fd;
diff --git a/libusb/os/sunos_usb.c b/libusb/os/sunos_usb.c
index d7be7de..761ca37 100644
--- a/libusb/os/sunos_usb.c
+++ b/libusb/os/sunos_usb.c
@@ -171,7 +171,7 @@ sunos_usb_ioctl(struct libusb_device *dev, int cmd)
nvlist_alloc(&nvlist, NV_UNIQUE_NAME_TYPE, KM_NOSLEEP);
nvlist_add_int32(nvlist, "port", dev->port_number);
- //find the hub path
+ /* find the hub path */
snprintf(path_arg, sizeof(path_arg), "/devices%s:hubd", hubpath);
usbi_dbg(DEVICE_CTX(dev), "ioctl hub path: %s", path_arg);
diff --git a/libusb/os/windows_winusb.c b/libusb/os/windows_winusb.c
index 65d288f..a30f3de 100644
--- a/libusb/os/windows_winusb.c
+++ b/libusb/os/windows_winusb.c
@@ -1492,7 +1492,7 @@ static int get_guid(struct libusb_context *ctx, char *dev_id, HDEVINFO *dev_info
// The GUID was read successfully
break;
} else if (s == ERROR_FILE_NOT_FOUND) {
- usbi_info(ctx, "no DeviceInterfaceGUID registered for '%s'", dev_id);
+ usbi_dbg(ctx, "no DeviceInterfaceGUID registered for '%s'", dev_id);
err = LIBUSB_ERROR_ACCESS;
goto exit;
} else if (s == ERROR_MORE_DATA) {
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index d4f0bc9..0fa03f1 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11899
+#define LIBUSB_NANO 11906