summaryrefslogtreecommitdiff
path: root/libusb/core.c
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2020-04-16 12:20:16 -0700
committerChris Dickens <christopher.a.dickens@gmail.com>2020-04-16 12:20:16 -0700
commitf0cce43f882d8b55d3abaacda110a4102d75de9a (patch)
tree85dd87e0f0766477c86176b0f51e13fd7becced4 /libusb/core.c
parent5c44ca955b3d7c41e6717514dc508f42faa2237b (diff)
downloadlibusb-f0cce43f882d8b55d3abaacda110a4102d75de9a.tar.gz
core: Fix definition and use of enum libusb_transfer_type
Since the beginning of the libusb-1.0, the libusb_transfer_type enum had a 1:1 mapping to the endpoint transfer type (bits 1:0 of the endpoint descriptor's bmAttributes). This was broken with the addition of bulk stream support because the value of LIBUSB_TRANSFER_TYPE_BULK_STREAM does not map to a valid value for an endpoint's transfer type. Fix this by splitting the endpoint's transfer type for its descriptor and the library's transfer type for its logical transfers into different enumerations. None of the values are altered, so applications testing an endpoint descriptor's bmAttributes field against the libusb_transfer_type enum values will still work. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Diffstat (limited to 'libusb/core.c')
-rw-r--r--libusb/core.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libusb/core.c b/libusb/core.c
index 2097fea..446ed83 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -460,6 +460,7 @@ if (cfg != desired)
* - \ref libusb_class_code
* - \ref libusb_descriptor_type
* - \ref libusb_endpoint_direction
+ * - \ref libusb_endpoint_transfer_type
* - \ref libusb_error
* - \ref libusb_iso_sync_type
* - \ref libusb_iso_usage_type
@@ -1094,7 +1095,7 @@ int API_EXPORTED libusb_get_max_iso_packet_size(libusb_device *dev,
struct libusb_config_descriptor *config;
const struct libusb_endpoint_descriptor *ep;
struct libusb_ss_endpoint_companion_descriptor *ss_ep_cmp;
- enum libusb_transfer_type ep_type;
+ enum libusb_endpoint_transfer_type ep_type;
uint16_t val;
int r;
int speed;
@@ -1124,11 +1125,11 @@ 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) {
val = ep->wMaxPacketSize;
- ep_type = (enum libusb_transfer_type) (ep->bmAttributes & 0x3);
+ ep_type = (enum libusb_endpoint_transfer_type) (ep->bmAttributes & 0x3);
r = val & 0x07ff;
- if (ep_type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS
- || ep_type == LIBUSB_TRANSFER_TYPE_INTERRUPT)
+ if (ep_type == LIBUSB_ENDPOINT_TRANSFER_TYPE_ISOCHRONOUS
+ || ep_type == LIBUSB_ENDPOINT_TRANSFER_TYPE_INTERRUPT)
r *= (1 + ((val >> 11) & 3));
}