summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-05-18 14:07:49 +0200
committerHans de Goede <hdegoede@redhat.com>2013-05-18 14:39:46 +0200
commit9f59875fbce9dc6bdb163e8558761a06400a9f18 (patch)
tree691228656d5f98ca814104028dd451ca01131ab2
parentf3fcf8402609d946d16eb2d9686bf76d7b0b8ae0 (diff)
downloadlibusb-9f59875fbce9dc6bdb163e8558761a06400a9f18.tar.gz
linux: Fix host_endian handling
-in 2 cases the passed in host_endian was not being set -get_config_descriptor was wrongly calling seek_to_next_config with host_endian set to 1, but the only case where host_endian is 1 is when reading the device-desc from usbfs, even in usbfs the config descriptors are in raw format Note that the 2nd change partly reverts commit 7f2e9f0776386997d2b4c4c47598ab88e3caeb7a "Linux: Fix usbfs/sysfs config descriptor handling on big-endian" Which commit msg says: "checked against Documentation/usb/proc_usb_info.txt" Well guess what, I checked the actual drivers/usb/core/devio.c code and Documentation/usb/proc_usb_info.txt is *wrong*. I'll send a patch to update it. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--libusb/os/linux_usbfs.c16
-rw-r--r--libusb/version_nano.h2
2 files changed, 11 insertions, 7 deletions
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
index 85ae8f5..7080dec 100644
--- a/libusb/os/linux_usbfs.c
+++ b/libusb/os/linux_usbfs.c
@@ -587,7 +587,7 @@ static int op_get_device_descriptor(struct libusb_device *dev,
*host_endian = 0;
return sysfs_get_device_descriptor(dev, buffer);
} else {
- *host_endian = 1;
+ *host_endian = 1; /* usbfs converts the device desc to host */
return usbfs_get_device_descriptor(dev, buffer);
}
}
@@ -649,8 +649,7 @@ static int sysfs_get_active_config(struct libusb_device *dev, int *config)
/* takes a usbfs/descriptors fd seeked to the start of a configuration, and
* seeks to the next one. */
-static int seek_to_next_config(struct libusb_context *ctx, int fd,
- int host_endian)
+static int seek_to_next_config(struct libusb_context *ctx, int fd)
{
struct libusb_config_descriptor config;
unsigned char tmp[6];
@@ -668,7 +667,7 @@ static int seek_to_next_config(struct libusb_context *ctx, int fd,
}
/* seek forward to end of config */
- usbi_parse_descriptor(tmp, "bbwbb", &config, host_endian);
+ usbi_parse_descriptor(tmp, "bbwbb", &config, 0);
off = lseek(fd, config.wTotalLength - sizeof(tmp), SEEK_CUR);
if (off < 0) {
usbi_err(ctx, "seek failed ret=%d errno=%d", off, errno);
@@ -745,7 +744,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, 0);
+ r = seek_to_next_config(DEVICE_CTX(dev), fd);
if (r < 0)
return r;
}
@@ -815,6 +814,8 @@ int linux_get_device_address (struct libusb_context *ctx, int detached,
static int op_get_active_config_descriptor(struct libusb_device *dev,
unsigned char *buffer, size_t len, int *host_endian)
{
+ /* Unlike the device desc. config descs. are always in raw format */
+ *host_endian = 0;
if (sysfs_has_descriptors) {
return sysfs_get_active_config_descriptor(dev, buffer, len);
} else {
@@ -839,7 +840,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, 1);
+ r = seek_to_next_config(ctx, fd);
if (r < 0)
return r;
config_index--;
@@ -864,6 +865,9 @@ static int op_get_config_descriptor(struct libusb_device *dev,
int fd;
int r;
+ /* Unlike the device desc. config descs. are always in raw format */
+ *host_endian = 0;
+
/* always read from usbfs: sysfs only has the active descriptor
* this will involve waking the device up, but oh well! */
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 7eaedda..ff9fd57 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10698
+#define LIBUSB_NANO 10699