Lines 1-5
Link Here
|
1 |
--- usb_libusb.c.orig 2013-08-01 17:14:17.000000000 +0800 |
1 |
--- usb_libusb.c.orig 2015-04-13 15:24:18 UTC |
2 |
+++ usb_libusb.c 2013-08-01 17:14:46.000000000 +0800 |
2 |
+++ usb_libusb.c |
3 |
@@ -37,7 +37,7 @@ |
3 |
@@ -37,7 +37,7 @@ |
4 |
#define TRACE_TAG TRACE_USB |
4 |
#define TRACE_TAG TRACE_USB |
5 |
#include "adb.h" |
5 |
#include "adb.h" |
Lines 22-24
Link Here
|
22 |
|
22 |
|
23 |
return (1); |
23 |
return (1); |
24 |
} |
24 |
} |
|
|
25 |
@@ -484,51 +488,13 @@ check_device(libusb_device *dev) |
26 |
goto fail; |
27 |
} |
28 |
|
29 |
- if (desc.iSerialNumber) { |
30 |
- // reading serial |
31 |
- uint16_t buffer[128] = {0}; |
32 |
- uint16_t languages[128] = {0}; |
33 |
- int languageCount = 0; |
34 |
- |
35 |
- memset(languages, 0, sizeof(languages)); |
36 |
- r = libusb_control_transfer(uh.devh, |
37 |
- LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_STANDARD | LIBUSB_RECIPIENT_DEVICE, |
38 |
- LIBUSB_REQUEST_GET_DESCRIPTOR, LIBUSB_DT_STRING << 8, |
39 |
- 0, (uint8_t *)languages, sizeof(languages), 0); |
40 |
- |
41 |
- if (r <= 0) { |
42 |
- D("check_device(): Failed to get languages count\n"); |
43 |
- goto fail; |
44 |
- } |
45 |
- |
46 |
- languageCount = (r - 2) / 2; |
47 |
- |
48 |
- for (i = 1; i <= languageCount; ++i) { |
49 |
- memset(buffer, 0, sizeof(buffer)); |
50 |
- |
51 |
- r = libusb_control_transfer(uh.devh, |
52 |
- LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_STANDARD | LIBUSB_RECIPIENT_DEVICE, |
53 |
- LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_STRING << 8) | desc.iSerialNumber, |
54 |
- languages[i], (uint8_t *)buffer, sizeof(buffer), 0); |
55 |
- |
56 |
- if (r > 0) { /* converting serial */ |
57 |
- int j = 0; |
58 |
- r /= 2; |
59 |
- |
60 |
- for (j = 1; j < r; ++j) |
61 |
- serial[j - 1] = buffer[j]; |
62 |
- |
63 |
- serial[j - 1] = '\0'; |
64 |
- break; /* languagesCount cycle */ |
65 |
- } |
66 |
- } |
67 |
- |
68 |
- if (register_device(&uh, serial) == 0) { |
69 |
- D("check_device(): Failed to register device\n"); |
70 |
- goto fail_interface; |
71 |
- } |
72 |
- |
73 |
- libusb_ref_device(dev); |
74 |
+ if (desc.iSerialNumber != 0) { |
75 |
+ libusb_get_string_descriptor_ascii(uh.devh, desc.iSerialNumber, |
76 |
+ (unsigned char *)uh.serial, sizeof(uh.serial)); |
77 |
+ } |
78 |
+ if (register_device(&uh, uh.serial) == 0) { |
79 |
+ D("check_device(): Failed to register device\n"); |
80 |
+ goto fail_interface; |
81 |
} |
82 |
} |
83 |
|