summaryrefslogtreecommitdiff
path: root/libusb/io.c
diff options
context:
space:
mode:
authorDaniel Drake <dsd@gentoo.org>2008-05-11 15:36:24 +0100
committerDaniel Drake <dsd@gentoo.org>2008-05-11 15:39:41 +0100
commitba5d9a45c06311204f51faef41d1ee215bb5b823 (patch)
tree17bf4d2ea98779e95a1b45a04c8b7ae671770d02 /libusb/io.c
parent7bedc3b2683f35ee1dd39a2ebe0ec05be0019f38 (diff)
downloadlibusb-ba5d9a45c06311204f51faef41d1ee215bb5b823.tar.gz
Endianness of control setup packets
Document behaviour where host-endian and bus-endian (little) should be used respectively. Also remove packed attribute from libusb_control_setup as all fields are naturally aligned.
Diffstat (limited to 'libusb/io.c')
-rw-r--r--libusb/io.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/libusb/io.c b/libusb/io.c
index 04ffc6e..133f849 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -315,6 +315,12 @@ if (r == 0 && actual_length == sizeof(data)) {
* packet.
* -# Submit the transfer.
*
+ * The multi-byte control setup fields (wValue, wIndex and wLength) must
+ * be given in little-endian byte order (the endianness of the USB bus).
+ * Endianness conversion is transparently handled by
+ * libusb_fill_control_setup() which is documented to accept host-endian
+ * values.
+ *
* Further considerations are needed when handling transfer completion in
* your callback function:
* - As you might expect, the setup packet will still be sitting at the start
@@ -722,19 +728,6 @@ API_EXPORTED int libusb_submit_transfer(struct libusb_transfer *transfer)
if (r < 0)
return LIBUSB_ERROR_OTHER;
- if (transfer->type == LIBUSB_TRANSFER_TYPE_CONTROL) {
- struct libusb_control_setup *setup =
- (struct libusb_control_setup *) transfer->buffer;
-
- usbi_dbg("RQT=%02x RQ=%02x VAL=%04x IDX=%04x length=%d",
- setup->bmRequestType, setup->bRequest, setup->wValue, setup->wIndex,
- setup->wLength);
-
- setup->wValue = cpu_to_le16(setup->wValue);
- setup->wIndex = cpu_to_le16(setup->wIndex);
- setup->wLength = cpu_to_le16(setup->wLength);
- }
-
add_to_flying_list(itransfer);
r = usbi_backend->submit_transfer(itransfer);
if (r) {