diff options
author | Marcus Comstedt <marcus@mc.pp.se> | 2010-09-22 20:09:44 +0200 |
---|---|---|
committer | Marcus Comstedt <marcus@mc.pp.se> | 2010-10-16 14:35:34 +0200 |
commit | 6f703a2e85a3098b3546a0ce254349b72b440628 (patch) | |
tree | 970699c66f897b02dfc4349c2eeb667b9abfe0f2 | |
parent | d340d2f57dc0d414ea66b1b556caaf8c98b1e967 (diff) | |
download | system_core-6f703a2e85a3098b3546a0ce254349b72b440628.zip system_core-6f703a2e85a3098b3546a0ce254349b72b440628.tar.gz system_core-6f703a2e85a3098b3546a0ce254349b72b440628.tar.bz2 |
Fix USB endianness bugs on Linux.
The fields device->idVendor and device->idProduct should not be
converted from little endian to native byteorder, because the
kernel has in fact done so already!
On the other hand, the descriptors read using raw ioctl:s in
register_device() do need to be converted.
Change-Id: I5fe08b626b14ead56a592b68d026690e343c2656
-rw-r--r-- | adb/usb_linux.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/adb/usb_linux.c b/adb/usb_linux.c index bb86813..2f7f870 100644 --- a/adb/usb_linux.c +++ b/adb/usb_linux.c @@ -191,9 +191,8 @@ static void find_usb_device(const char *base, continue; } - vid = __le16_to_cpu(device->idVendor); - pid = __le16_to_cpu(device->idProduct); - pid = devdesc[10] | (devdesc[11] << 8); + vid = device->idVendor; + pid = device->idProduct; DBGX("[ %s is V:%04x P:%04x ]\n", devname, vid, pid); // should have config descriptor next @@ -617,7 +616,7 @@ static void register_device(const char *dev_name, ctrl.bRequestType = USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE; ctrl.bRequest = USB_REQ_GET_DESCRIPTOR; ctrl.wValue = (USB_DT_STRING << 8) | serial_index; - ctrl.wIndex = languages[i]; + ctrl.wIndex = __le16_to_cpu(languages[i]); ctrl.wLength = sizeof(buffer); ctrl.data = buffer; @@ -627,7 +626,7 @@ static void register_device(const char *dev_name, // skip first word, and copy the rest to the serial string, changing shorts to bytes. result /= 2; for (i = 1; i < result; i++) - serial[i - 1] = buffer[i]; + serial[i - 1] = __le16_to_cpu(buffer[i]); serial[i - 1] = 0; break; } |