Fixed target is not detected after sdbd is restarted
authorshingil.kang <shingil.kang@samsung.com>
Wed, 6 Jan 2016 05:59:14 +0000 (14:59 +0900)
committershingil.kang <shingil.kang@samsung.com>
Wed, 6 Jan 2016 05:59:14 +0000 (14:59 +0900)
Change-Id: Iefb1b7bb357ab71eb496131b8c4ecc12e8a073ff
Signed-off-by: shingil.kang <shingil.kang@samsung.com>
src/usb_darwin.c

index c2c2835b8cc76596230ad3a49c3484217feb7ec7..bd8b7a60bac5370474a9b2133317b605753e844e 100755 (executable)
@@ -592,12 +592,18 @@ int sdb_usb_read(usb_handle *h, void *data, int len) {
 
     kr = (*h->interface)->ReadPipe(h->interface, h->end_point[0], data, &size);
 
-    if (kIOReturnSuccess != kr) {
-        LOG_DEBUG("Unable to perform bulk read (%08x)\n", kr);
-        return -1;
+    if (kIOUSBPipeStalled == kr) {
+        LOG_DEBUG("Pipe stalled, clearing stall.\n");
+        (*h->interface)->ClearPipeStall(h->interface, h->end_point[0]);
+        kr = (*h->interface)->ReadPipe(h->interface, h->end_point[0], data, &size);
     }
 
-    return 0;
+    if (kIOReturnSuccess == kr) {
+        return 0;
+    }
+
+    LOG_DEBUG("Unable to perform bulk read (%08x)\n", kr);
+    return -1;
 }
 
 int sdb_usb_close(usb_handle *h) {