diff options
Diffstat (limited to 'adb/usb_linux.c')
-rw-r--r-- | adb/usb_linux.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/adb/usb_linux.c b/adb/usb_linux.c index cd61083..4d55b74 100644 --- a/adb/usb_linux.c +++ b/adb/usb_linux.c @@ -45,7 +45,7 @@ /* usb scan debugging is waaaay too verbose */ #define DBGX(x...) -static adb_mutex_t usb_lock = ADB_MUTEX_INITIALIZER; +ADB_MUTEX_DEFINE( usb_lock ); struct usb_handle { @@ -369,6 +369,7 @@ static int usb_bulk_read(usb_handle *h, void *data, int len) h->reaper_thread = pthread_self(); adb_mutex_unlock(&h->lock); res = ioctl(h->desc, USBDEVFS_REAPURB, &out); + int saved_errno = errno; adb_mutex_lock(&h->lock); h->reaper_thread = 0; if(h->dead) { @@ -376,7 +377,7 @@ static int usb_bulk_read(usb_handle *h, void *data, int len) break; } if(res < 0) { - if(errno == EINTR) { + if(saved_errno == EINTR) { continue; } D("[ reap urb - error ]\n"); @@ -604,6 +605,7 @@ static void register_device(const char *dev_name, ctrl.wIndex = 0; ctrl.wLength = sizeof(languages); ctrl.data = languages; + ctrl.timeout = 1000; result = ioctl(usb->desc, USBDEVFS_CONTROL, &ctrl); if (result > 0) @@ -619,6 +621,7 @@ static void register_device(const char *dev_name, ctrl.wIndex = __le16_to_cpu(languages[i]); ctrl.wLength = sizeof(buffer); ctrl.data = buffer; + ctrl.timeout = 1000; result = ioctl(usb->desc, USBDEVFS_CONTROL, &ctrl); if (result > 0) { @@ -685,4 +688,3 @@ void usb_init() fatal_errno("cannot create input thread"); } } - |