Linux: Fix usbfs/sysfs config descriptor handling on big-endian
authorHector Martin <hector@marcansoft.com>
Wed, 25 Aug 2010 01:21:57 +0000 (03:21 +0200)
committerPeter Stuge <peter@stuge.se>
Mon, 22 Nov 2010 04:46:37 +0000 (05:46 +0100)
usbfs endian-swaps, sysfs doesn't, not the other way around. Fixes #51;
descriptor endian parsing is backwards using sysfs on big-endian hosts.
usbfs is untested.

Signed-off-by: Hector Martin <hector@marcansoft.com>
[stuge: checked against Documentation/usb/proc_usb_info.txt]

libusb/os/linux_usbfs.c

index a44688d..5c2a6e8 100644 (file)
@@ -489,7 +489,7 @@ static int sysfs_get_active_config_descriptor(struct libusb_device *dev,
                if (off < 0)
                        return LIBUSB_ERROR_IO;
 
-               r = seek_to_next_config(DEVICE_CTX(dev), fd, 1);
+               r = seek_to_next_config(DEVICE_CTX(dev), fd, 0);
                if (r < 0)
                        return r;
        }
@@ -544,7 +544,7 @@ static int get_config_descriptor(struct libusb_context *ctx, int fd,
        /* might need to skip some configuration descriptors to reach the
         * requested configuration */
        while (config_index > 0) {
-               r = seek_to_next_config(ctx, fd, 0);
+               r = seek_to_next_config(ctx, fd, 1);
                if (r < 0)
                        return r;
                config_index--;