diff options
author | Steve Kondik <steve@cyngn.com> | 2015-11-16 14:45:11 -0800 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-11-16 14:45:11 -0800 |
commit | b9cf99af8615d4922e3f4f4c79c41e9e6dd27de1 (patch) | |
tree | f621c36ac31c2d5661f7dcc05f705ad25fc2e947 /adb | |
parent | 6444253a9b298ca63179bf075a982d37b7ec7892 (diff) | |
parent | d2ea2dace4b95b2efe741700742edb27e8f9cb78 (diff) | |
download | system_core-b9cf99af8615d4922e3f4f4c79c41e9e6dd27de1.zip system_core-b9cf99af8615d4922e3f4f4c79c41e9e6dd27de1.tar.gz system_core-b9cf99af8615d4922e3f4f4c79c41e9e6dd27de1.tar.bz2 |
Merge branch 'LA.BF64.1.2.2_rb4.7' of git://codeaurora.org/platform/system/core into cm-13.0
Diffstat (limited to 'adb')
-rw-r--r-- | adb/usb_linux_client.cpp | 59 |
1 files changed, 27 insertions, 32 deletions
diff --git a/adb/usb_linux_client.cpp b/adb/usb_linux_client.cpp index f3db346..44df695 100644 --- a/adb/usb_linux_client.cpp +++ b/adb/usb_linux_client.cpp @@ -333,37 +333,35 @@ static void init_functionfs(struct usb_handle *h) v2_descriptor.hs_descs = hs_descriptors; v2_descriptor.ss_descs = ss_descriptors; - if (h->control < 0) { // might have already done this before - D("OPENING %s\n", USB_FFS_ADB_EP0); - h->control = adb_open(USB_FFS_ADB_EP0, O_RDWR); - if (h->control < 0) { - D("[ %s: cannot open control endpoint: errno=%d]\n", USB_FFS_ADB_EP0, errno); - goto err; - } - - ret = adb_write(h->control, &v2_descriptor, sizeof(v2_descriptor)); - if (ret < 0) { - v1_descriptor.header.magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC); - v1_descriptor.header.length = cpu_to_le32(sizeof(v1_descriptor)); - v1_descriptor.header.fs_count = 3; - v1_descriptor.header.hs_count = 3; - v1_descriptor.fs_descs = fs_descriptors; - v1_descriptor.hs_descs = hs_descriptors; - D("[ %s: Switching to V1_descriptor format errno=%d ]\n", USB_FFS_ADB_EP0, errno); - ret = adb_write(h->control, &v1_descriptor, sizeof(v1_descriptor)); - if (ret < 0) { - D("[ %s: write descriptors failed: errno=%d ]\n", USB_FFS_ADB_EP0, errno); - goto err; - } - } + D("OPENING %s\n", USB_FFS_ADB_EP0); + h->control = adb_open(USB_FFS_ADB_EP0, O_RDWR); + if (h->control < 0) { + D("[ %s: cannot open control endpoint: errno=%d]\n", USB_FFS_ADB_EP0, errno); + goto err; + } - ret = adb_write(h->control, &strings, sizeof(strings)); + ret = adb_write(h->control, &v2_descriptor, sizeof(v2_descriptor)); + if (ret < 0) { + v1_descriptor.header.magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC); + v1_descriptor.header.length = cpu_to_le32(sizeof(v1_descriptor)); + v1_descriptor.header.fs_count = 3; + v1_descriptor.header.hs_count = 3; + v1_descriptor.fs_descs = fs_descriptors; + v1_descriptor.hs_descs = hs_descriptors; + D("[ %s: Switching to V1_descriptor format errno=%d ]\n", USB_FFS_ADB_EP0, errno); + ret = adb_write(h->control, &v1_descriptor, sizeof(v1_descriptor)); if (ret < 0) { - D("[ %s: writing strings failed: errno=%d]\n", USB_FFS_ADB_EP0, errno); + D("[ %s: write descriptors failed: errno=%d ]\n", USB_FFS_ADB_EP0, errno); goto err; } } + ret = adb_write(h->control, &strings, sizeof(strings)); + if (ret < 0) { + D("[ %s: writing strings failed: errno=%d]\n", USB_FFS_ADB_EP0, errno); + goto err; + } + h->bulk_out = adb_open(USB_FFS_ADB_OUT, O_RDWR); if (h->bulk_out < 0) { D("[ %s: cannot open bulk-out ep: errno=%d ]\n", USB_FFS_ADB_OUT, errno); @@ -401,14 +399,14 @@ static void *usb_ffs_open_thread(void *x) while (true) { // wait until the USB device needs opening adb_mutex_lock(&usb->lock); - while (usb->control != -1 && usb->bulk_in != -1 && usb->bulk_out != -1) + while (usb->control != -1) adb_cond_wait(&usb->notify, &usb->lock); adb_mutex_unlock(&usb->lock); while (true) { init_functionfs(usb); - if (usb->control >= 0 && usb->bulk_in >= 0 && usb->bulk_out >= 0) + if (usb->control >= 0) break; adb_sleep_ms(1000); @@ -500,13 +498,10 @@ static void usb_ffs_kick(usb_handle *h) D("[ kick: sink (fd=%d) clear halt failed (%d) ]", h->bulk_out, errno); adb_mutex_lock(&h->lock); - - // don't close ep0 here, since we may not need to reinitialize it with - // the same descriptors again. if however ep1/ep2 fail to re-open in - // init_functionfs, only then would we close and open ep0 again. + adb_close(h->control); adb_close(h->bulk_out); adb_close(h->bulk_in); - h->bulk_out = h->bulk_in = -1; + h->control = h->bulk_out = h->bulk_in = -1; // notify usb_ffs_open_thread that we are disconnected adb_cond_signal(&h->notify); |