diff --git a/adb/Android.mk b/adb/Android.mk
index 2d426d9..7faca9b 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -80,9 +80,6 @@
 ifeq ($(USE_SYSDEPS_WIN32),)
 	LOCAL_STATIC_LIBRARIES += libcutils
 endif
-ifeq ($(HOST_OS),linux)
-  LOCAL_STATIC_LIBRARIES += libusbhost
-endif
 
 include $(BUILD_HOST_EXECUTABLE)
 
diff --git a/adb/usb_linux.c b/adb/usb_linux.c
index eb10118..bb86813 100644
--- a/adb/usb_linux.c
+++ b/adb/usb_linux.c
@@ -19,7 +19,14 @@
 #include <unistd.h>
 #include <string.h>
 
-#include <usbhost/usbhost.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <ctype.h>
+
 #include <linux/usbdevice_fs.h>
 #include <linux/version.h>
 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
@@ -27,6 +34,7 @@
 #else
 #include <linux/usb_ch9.h>
 #endif
+#include <asm/byteorder.h>
 
 #include "sysdeps.h"
 
@@ -44,19 +52,28 @@
     usb_handle *prev;
     usb_handle *next;
 
-    struct usb_device *device;
-    struct usb_endpoint *ep_in;
-    struct usb_endpoint *ep_out;
+    char fname[64];
+    int desc;
+    unsigned char ep_in;
+    unsigned char ep_out;
 
-    adb_cond_t notify_in;
-    adb_cond_t notify_out;
-    adb_mutex_t lock;
+    unsigned zero_mask;
+    unsigned writeable;
 
-    int read_result, write_result;
-    int zero_mask;
+    struct usbdevfs_urb urb_in;
+    struct usbdevfs_urb urb_out;
+
+    int urb_in_busy;
+    int urb_out_busy;
     int dead;
 
-    // Thread ID for our reaper thread
+    adb_cond_t notify;
+    adb_mutex_t lock;
+
+    // for garbage collecting disconnected devices
+    int mark;
+
+    // ID of thread currently in REAPURB
     pthread_t reaper_thread;
 };
 
@@ -70,8 +87,10 @@
     usb_handle *usb;
 
     adb_mutex_lock(&usb_lock);
-    for (usb = handle_list.next; usb != &handle_list; usb = usb->next) {
-        if (!strcmp(usb_device_get_name(usb->device), dev_name)) {
+    for(usb = handle_list.next; usb != &handle_list; usb = usb->next){
+        if(!strcmp(usb->fname, dev_name)) {
+            // set mark flag to indicate this device is still alive
+            usb->mark = 1;
             adb_mutex_unlock(&usb_lock);
             return 1;
         }
@@ -80,204 +99,185 @@
     return 0;
 }
 
-static void kick_disconnected_device(const char *devname)
+static void kick_disconnected_devices()
 {
     usb_handle *usb;
 
     adb_mutex_lock(&usb_lock);
-    /* kick the device if it is in our list */
-    for (usb = handle_list.next; usb != &handle_list; usb = usb->next) {
-        if (!strcmp(devname, usb_device_get_name(usb->device)))
+    // kick any devices in the device list that were not found in the device scan
+    for(usb = handle_list.next; usb != &handle_list; usb = usb->next){
+        if (usb->mark == 0) {
             usb_kick(usb);
+        } else {
+            usb->mark = 0;
+        }
     }
     adb_mutex_unlock(&usb_lock);
 
 }
 
-static void* reaper_thread(void* arg)
+static void register_device(const char *dev_name, unsigned char ep_in, unsigned char ep_out,
+                            int ifc, int serial_index, unsigned zero_mask);
+
+static inline int badname(const char *name)
 {
-    struct usb_handle* h = (struct usb_handle *)arg;
-    int ep_in = usb_endpoint_number(h->ep_in);
-    int ep_out = usb_endpoint_number(h->ep_out);
-    int reaped_ep, res;
-
-    while (1) {
-        D("[ reap urb - wait ]\n");
-        adb_mutex_unlock(&h->lock);
-        res = usb_endpoint_wait(h->device, &reaped_ep);
-        adb_mutex_lock(&h->lock);
-        if(h->dead) {
-            res = -1;
-            break;
-        }
-
-        D("[ reaped ep %d ret = %d ]\n", reaped_ep, res);
-
-        if (reaped_ep == ep_in) {
-            D("[ reap urb - IN complete ]\n");
-            h->read_result = res;
-            adb_cond_broadcast(&h->notify_in);
-        }
-        if (reaped_ep == ep_out) {
-            D("[ reap urb - OUT compelete ]\n");
-            h->write_result = res;
-            adb_cond_broadcast(&h->notify_out);
-        }
+    while(*name) {
+        if(!isdigit(*name++)) return 1;
     }
-
-    return NULL;
+    return 0;
 }
 
-static void register_device(struct usb_device *device, int interface,
-        struct usb_endpoint *ep_in, struct usb_endpoint *ep_out)
+static void find_usb_device(const char *base,
+        void (*register_device_callback)
+                (const char *, unsigned char, unsigned char, int, int, unsigned))
 {
-    usb_handle* usb = 0;
-    int ret = 0;
-    int writeable;
-    char *serial;
-    pthread_attr_t   attr;
-    const char* dev_name = usb_device_get_name(device);
+    char busname[32], devname[32];
+    unsigned char local_ep_in, local_ep_out;
+    DIR *busdir , *devdir ;
+    struct dirent *de;
+    int fd ;
 
-        /* Since Linux will not reassign the device ID (and dev_name)
-        ** as long as the device is open, we can add to the list here
-        ** once we open it and remove from the list when we're finally
-        ** closed and everything will work out fine.
-        **
-        ** If we have a usb_handle on the list 'o handles with a matching
-        ** name, we have no further work to do.
-        */
-    adb_mutex_lock(&usb_lock);
-    for (usb = handle_list.next; usb != &handle_list; usb = usb->next) {
-        if (!strcmp(usb_device_get_name(usb->device), dev_name)) {
-            adb_mutex_unlock(&usb_lock);
-            return;
-        }
-    }
-    adb_mutex_unlock(&usb_lock);
+    busdir = opendir(base);
+    if(busdir == 0) return;
 
-    usb = calloc(1, sizeof(usb_handle));
-    adb_cond_init(&usb->notify_in, 0);
-    adb_cond_init(&usb->notify_out, 0);
-    adb_mutex_init(&usb->lock, 0);
+    while((de = readdir(busdir)) != 0) {
+        if(badname(de->d_name)) continue;
 
-    usb->device = device;
-    usb->ep_in = ep_in;
-    usb->ep_out = ep_out;
-    usb->zero_mask = usb_endpoint_max_packet(usb->ep_out) - 1;
+        snprintf(busname, sizeof busname, "%s/%s", base, de->d_name);
+        devdir = opendir(busname);
+        if(devdir == 0) continue;
 
-    D("[ usb open %s ]\n", dev_name);
-    writeable = usb_device_is_writeable(device);
-    if (writeable) {
-        ret = usb_device_claim_interface(device, interface);
-        if(ret != 0) goto fail;
-    }
+//        DBGX("[ scanning %s ]\n", busname);
+        while((de = readdir(devdir))) {
+            unsigned char devdesc[256];
+            unsigned char* bufptr = devdesc;
+            unsigned char* bufend;
+            struct usb_device_descriptor* device;
+            struct usb_config_descriptor* config;
+            struct usb_interface_descriptor* interface;
+            struct usb_endpoint_descriptor *ep1, *ep2;
+            unsigned zero_mask = 0;
+            unsigned vid, pid;
+            size_t desclength;
 
-        /* add to the end of the active handles */
-    adb_mutex_lock(&usb_lock);
-    usb->next = &handle_list;
-    usb->prev = handle_list.prev;
-    usb->prev->next = usb;
-    usb->next->prev = usb;
-    adb_mutex_unlock(&usb_lock);
+            if(badname(de->d_name)) continue;
+            snprintf(devname, sizeof devname, "%s/%s", busname, de->d_name);
 
-    pthread_attr_init(&attr);
-    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-    pthread_create(&usb->reaper_thread, &attr, reaper_thread, usb);
-
-    serial = usb_device_get_serial(device);
-    register_usb_transport(usb, serial, writeable);
-    if (serial)
-        free(serial);
-    return;
-
-fail:
-    D("[ usb open %s error=%d, err_str = %s]\n",
-        dev_name,  errno, strerror(errno));
-    if (usb->ep_in)
-        usb_endpoint_close(usb->ep_in);
-    if (usb->ep_out)
-        usb_endpoint_close(usb->ep_out);
-    if(device) {
-        usb_device_close(device);
-    }
-    free(usb);
-}
-
-static void check_usb_device(const char *devname) {
-    struct usb_device *device;
-    struct usb_descriptor_iter iter;
-    struct usb_descriptor_header* header;
-    struct usb_interface_descriptor* interface;
-    struct usb_endpoint_descriptor *ep1, *ep2;
-    struct usb_endpoint *ep_in = NULL, *ep_out = NULL;
-    uint16_t vid, pid;
-
-    if(known_device(devname)) {
-        DBGX("skipping %s\n", devname);
-        return;
-    }
-
-    device = usb_device_open(devname);
-    if (!device) return;
-
-    vid = usb_device_get_vendor_id(device);
-    pid = usb_device_get_product_id(device);
-    DBGX("[ %s is V:%04x P:%04x ]\n", devname, vid, pid);
-
-    // loop through all the descriptors and look for the ADB interface
-    usb_descriptor_iter_init(device, &iter);
-
-    while ((header = usb_descriptor_iter_next(&iter)) != NULL) {
-        if (header->bDescriptorType == USB_DT_INTERFACE) {
-            interface = (struct usb_interface_descriptor *)header;
-
-            DBGX("bInterfaceClass: %d,  bInterfaceSubClass: %d,"
-                 "bInterfaceProtocol: %d, bNumEndpoints: %d\n",
-                 interface->bInterfaceClass, interface->bInterfaceSubClass,
-                 interface->bInterfaceProtocol, interface->bNumEndpoints);
-
-            if (interface->bNumEndpoints == 2 &&
-                    is_adb_interface(vid, pid, interface->bInterfaceClass,
-                    interface->bInterfaceSubClass, interface->bInterfaceProtocol))  {
-
-                DBGX("looking for bulk endpoints\n");
-                    // looks like ADB...
-                ep1 = (struct usb_endpoint_descriptor *)usb_descriptor_iter_next(&iter);
-                ep2 = (struct usb_endpoint_descriptor *)usb_descriptor_iter_next(&iter);
-
-                if (!ep1 || !ep2 ||
-                    ep1->bDescriptorType != USB_DT_ENDPOINT ||
-                    ep2->bDescriptorType != USB_DT_ENDPOINT) {
-                    D("endpoints not found\n");
-                    continue;
-                }
-
-                    // both endpoints should be bulk
-                if (ep1->bmAttributes != USB_ENDPOINT_XFER_BULK ||
-                    ep2->bmAttributes != USB_ENDPOINT_XFER_BULK) {
-                    D("bulk endpoints not found\n");
-                    continue;
-                }
-
-                    // we have a match.  now we just need to figure out which is in and which is out.
-                if (ep1->bEndpointAddress & USB_ENDPOINT_DIR_MASK) {
-                    ep_in = usb_endpoint_open(device, ep1);
-                    ep_out = usb_endpoint_open(device, ep2);
-                } else {
-                    ep_in = usb_endpoint_open(device, ep2);
-                    ep_out = usb_endpoint_open(device, ep1);
-                }
-
-                register_device(device, interface->bInterfaceNumber, ep_in, ep_out);
-                // so we don't free it at the bottom
-                device = NULL;
-                break;
+            if(known_device(devname)) {
+                DBGX("skipping %s\n", devname);
+                continue;
             }
-        }
-    } // end of while
 
-    if (device)
-        usb_device_close(device);
+//            DBGX("[ scanning %s ]\n", devname);
+            if((fd = unix_open(devname, O_RDONLY)) < 0) {
+                continue;
+            }
+
+            desclength = adb_read(fd, devdesc, sizeof(devdesc));
+            bufend = bufptr + desclength;
+
+                // should have device and configuration descriptors, and atleast two endpoints
+            if (desclength < USB_DT_DEVICE_SIZE + USB_DT_CONFIG_SIZE) {
+                D("desclength %d is too small\n", desclength);
+                adb_close(fd);
+                continue;
+            }
+
+            device = (struct usb_device_descriptor*)bufptr;
+            bufptr += USB_DT_DEVICE_SIZE;
+
+            if((device->bLength != USB_DT_DEVICE_SIZE) || (device->bDescriptorType != USB_DT_DEVICE)) {
+                adb_close(fd);
+                continue;
+            }
+
+            vid = __le16_to_cpu(device->idVendor);
+            pid = __le16_to_cpu(device->idProduct);
+            pid = devdesc[10] | (devdesc[11] << 8);
+            DBGX("[ %s is V:%04x P:%04x ]\n", devname, vid, pid);
+
+                // should have config descriptor next
+            config = (struct usb_config_descriptor *)bufptr;
+            bufptr += USB_DT_CONFIG_SIZE;
+            if (config->bLength != USB_DT_CONFIG_SIZE || config->bDescriptorType != USB_DT_CONFIG) {
+                D("usb_config_descriptor not found\n");
+                adb_close(fd);
+                continue;
+            }
+
+                // loop through all the descriptors and look for the ADB interface
+            while (bufptr < bufend) {
+                unsigned char length = bufptr[0];
+                unsigned char type = bufptr[1];
+
+                if (type == USB_DT_INTERFACE) {
+                    interface = (struct usb_interface_descriptor *)bufptr;
+                    bufptr += length;
+
+                    if (length != USB_DT_INTERFACE_SIZE) {
+                        D("interface descriptor has wrong size\n");
+                        break;
+                    }
+
+                    DBGX("bInterfaceClass: %d,  bInterfaceSubClass: %d,"
+                         "bInterfaceProtocol: %d, bNumEndpoints: %d\n",
+                         interface->bInterfaceClass, interface->bInterfaceSubClass,
+                         interface->bInterfaceProtocol, interface->bNumEndpoints);
+
+                    if (interface->bNumEndpoints == 2 &&
+                            is_adb_interface(vid, pid, interface->bInterfaceClass,
+                            interface->bInterfaceSubClass, interface->bInterfaceProtocol))  {
+
+                        DBGX("looking for bulk endpoints\n");
+                            // looks like ADB...
+                        ep1 = (struct usb_endpoint_descriptor *)bufptr;
+                        bufptr += USB_DT_ENDPOINT_SIZE;
+                        ep2 = (struct usb_endpoint_descriptor *)bufptr;
+                        bufptr += USB_DT_ENDPOINT_SIZE;
+
+                        if (bufptr > devdesc + desclength ||
+                            ep1->bLength != USB_DT_ENDPOINT_SIZE ||
+                            ep1->bDescriptorType != USB_DT_ENDPOINT ||
+                            ep2->bLength != USB_DT_ENDPOINT_SIZE ||
+                            ep2->bDescriptorType != USB_DT_ENDPOINT) {
+                            D("endpoints not found\n");
+                            break;
+                        }
+
+                            // both endpoints should be bulk
+                        if (ep1->bmAttributes != USB_ENDPOINT_XFER_BULK ||
+                            ep2->bmAttributes != USB_ENDPOINT_XFER_BULK) {
+                            D("bulk endpoints not found\n");
+                            continue;
+                        }
+                            /* aproto 01 needs 0 termination */
+                        if(interface->bInterfaceProtocol == 0x01) {
+                            zero_mask = ep1->wMaxPacketSize - 1;
+                        }
+
+                            // we have a match.  now we just need to figure out which is in and which is out.
+                        if (ep1->bEndpointAddress & USB_ENDPOINT_DIR_MASK) {
+                            local_ep_in = ep1->bEndpointAddress;
+                            local_ep_out = ep2->bEndpointAddress;
+                        } else {
+                            local_ep_in = ep2->bEndpointAddress;
+                            local_ep_out = ep1->bEndpointAddress;
+                        }
+
+                        register_device_callback(devname, local_ep_in, local_ep_out,
+                                interface->bInterfaceNumber, device->iSerialNumber, zero_mask);
+                        break;
+                    }
+                } else {
+                    bufptr += length;
+                }
+            } // end of while
+
+            adb_close(fd);
+        } // end of devdir while
+        closedir(devdir);
+    } //end of busdir while
+    closedir(busdir);
 }
 
 void usb_cleanup()
@@ -286,8 +286,17 @@
 
 static int usb_bulk_write(usb_handle *h, const void *data, int len)
 {
-    struct usb_endpoint *ep = h->ep_out;
+    struct usbdevfs_urb *urb = &h->urb_out;
     int res;
+    struct timeval tv;
+    struct timespec ts;
+
+    memset(urb, 0, sizeof(*urb));
+    urb->type = USBDEVFS_URB_TYPE_BULK;
+    urb->endpoint = h->ep_out;
+    urb->status = -1;
+    urb->buffer = (void*) data;
+    urb->buffer_length = len;
 
     D("++ write ++\n");
 
@@ -296,15 +305,32 @@
         res = -1;
         goto fail;
     }
-    res = usb_endpoint_queue(ep, (void *)data, len);
+    do {
+        res = ioctl(h->desc, USBDEVFS_SUBMITURB, urb);
+    } while((res < 0) && (errno == EINTR));
+
     if(res < 0) {
         goto fail;
     }
 
-    res = pthread_cond_wait(&h->notify_out, &h->lock);
-    if (!res)
-        res = h->write_result;
-
+    res = -1;
+    h->urb_out_busy = 1;
+    for(;;) {
+        /* time out after five seconds */
+        gettimeofday(&tv, NULL);
+        ts.tv_sec = tv.tv_sec + 5;
+        ts.tv_nsec = tv.tv_usec * 1000L;
+        res = pthread_cond_timedwait(&h->notify, &h->lock, &ts);
+        if(res < 0 || h->dead) {
+            break;
+        }
+        if(h->urb_out_busy == 0) {
+            if(urb->status == 0) {
+                res = urb->actual_length;
+            }
+            break;
+        }
+    }
 fail:
     adb_mutex_unlock(&h->lock);
     D("-- write --\n");
@@ -313,27 +339,75 @@
 
 static int usb_bulk_read(usb_handle *h, void *data, int len)
 {
-    struct usb_endpoint *ep = h->ep_in;
+    struct usbdevfs_urb *urb = &h->urb_in;
+    struct usbdevfs_urb *out = NULL;
     int res;
 
+    memset(urb, 0, sizeof(*urb));
+    urb->type = USBDEVFS_URB_TYPE_BULK;
+    urb->endpoint = h->ep_in;
+    urb->status = -1;
+    urb->buffer = data;
+    urb->buffer_length = len;
+
+
     adb_mutex_lock(&h->lock);
     if(h->dead) {
         res = -1;
         goto fail;
     }
-    res = usb_endpoint_queue(ep, data, len);
-    if (res < 0) {
+    do {
+        res = ioctl(h->desc, USBDEVFS_SUBMITURB, urb);
+    } while((res < 0) && (errno == EINTR));
+
+    if(res < 0) {
         goto fail;
     }
-    res = pthread_cond_wait(&h->notify_in, &h->lock);
-    if (!res)
-        res = h->read_result;
 
+    h->urb_in_busy = 1;
+    for(;;) {
+        D("[ reap urb - wait ]\n");
+        h->reaper_thread = pthread_self();
+        adb_mutex_unlock(&h->lock);
+        res = ioctl(h->desc, USBDEVFS_REAPURB, &out);
+        adb_mutex_lock(&h->lock);
+        h->reaper_thread = 0;
+        if(h->dead) {
+            res = -1;
+            break;
+        }
+        if(res < 0) {
+            if(errno == EINTR) {
+                continue;
+            }
+            D("[ reap urb - error ]\n");
+            break;
+        }
+        D("[ urb @%p status = %d, actual = %d ]\n",
+            out, out->status, out->actual_length);
+
+        if(out == &h->urb_in) {
+            D("[ reap urb - IN complete ]\n");
+            h->urb_in_busy = 0;
+            if(urb->status == 0) {
+                res = urb->actual_length;
+            } else {
+                res = -1;
+            }
+            break;
+        }
+        if(out == &h->urb_out) {
+            D("[ reap urb - OUT compelete ]\n");
+            h->urb_out_busy = 0;
+            adb_cond_broadcast(&h->notify);
+        }
+    }
 fail:
     adb_mutex_unlock(&h->lock);
     return res;
 }
 
+
 int usb_write(usb_handle *h, const void *_data, int len)
 {
     unsigned char *data = (unsigned char*) _data;
@@ -364,7 +438,7 @@
         data += xfer;
     }
 
-    if(need_zero) {
+    if(need_zero){
         n = usb_bulk_write(h, _data, 0);
         return n;
     }
@@ -381,9 +455,11 @@
     while(len > 0) {
         int xfer = (len > 4096) ? 4096 : len;
 
+        D("[ usb read %d fd = %d], fname=%s\n", xfer, h->desc, h->fname);
         n = usb_bulk_read(h, data, xfer);
+        D("[ usb read %d ] = %d, fname=%s\n", xfer, n, h->fname);
         if(n != xfer) {
-            if(errno == ETIMEDOUT && h->device) {
+            if((errno == ETIMEDOUT) && (h->desc != -1)) {
                 D("[ timeout ]\n");
                 if(n > 0){
                     data += n;
@@ -406,12 +482,12 @@
 
 void usb_kick(usb_handle *h)
 {
-    D("[ kicking %p (fd = %s) ]\n", h, usb_device_get_name(h->device));
+    D("[ kicking %p (fd = %d) ]\n", h, h->desc);
     adb_mutex_lock(&h->lock);
     if(h->dead == 0) {
         h->dead = 1;
 
-        if (usb_device_is_writeable(h->device)) {
+        if (h->writeable) {
             /* HACK ALERT!
             ** Sometimes we get stuck in ioctl(USBDEVFS_REAPURB).
             ** This is a workaround for that problem.
@@ -425,10 +501,13 @@
             ** but this ensures that a reader blocked on REAPURB
             ** will get unblocked
             */
-            usb_endpoint_cancel(h->ep_in);
-            usb_endpoint_cancel(h->ep_out);
-            adb_cond_broadcast(&h->notify_in);
-            adb_cond_broadcast(&h->notify_out);
+            ioctl(h->desc, USBDEVFS_DISCARDURB, &h->urb_in);
+            ioctl(h->desc, USBDEVFS_DISCARDURB, &h->urb_out);
+            h->urb_in.status = -ENODEV;
+            h->urb_out.status = -ENODEV;
+            h->urb_in_busy = 0;
+            h->urb_out_busy = 0;
+            adb_cond_broadcast(&h->notify);
         } else {
             unregister_usb_transport(h);
         }
@@ -445,14 +524,148 @@
     h->prev = 0;
     h->next = 0;
 
-    usb_device_close(h->device);
-    D("[ usb closed %p ]\n", h);
+    adb_close(h->desc);
+    D("[ usb closed %p (fd = %d) ]\n", h, h->desc);
     adb_mutex_unlock(&usb_lock);
 
     free(h);
     return 0;
 }
 
+static void register_device(const char *dev_name,
+                            unsigned char ep_in, unsigned char ep_out,
+                            int interface, int serial_index, unsigned zero_mask)
+{
+    usb_handle* usb = 0;
+    int n = 0;
+    char serial[256];
+
+        /* Since Linux will not reassign the device ID (and dev_name)
+        ** as long as the device is open, we can add to the list here
+        ** once we open it and remove from the list when we're finally
+        ** closed and everything will work out fine.
+        **
+        ** If we have a usb_handle on the list 'o handles with a matching
+        ** name, we have no further work to do.
+        */
+    adb_mutex_lock(&usb_lock);
+    for(usb = handle_list.next; usb != &handle_list; usb = usb->next){
+        if(!strcmp(usb->fname, dev_name)) {
+            adb_mutex_unlock(&usb_lock);
+            return;
+        }
+    }
+    adb_mutex_unlock(&usb_lock);
+
+    D("[ usb located new device %s (%d/%d/%d) ]\n",
+        dev_name, ep_in, ep_out, interface);
+    usb = calloc(1, sizeof(usb_handle));
+    strcpy(usb->fname, dev_name);
+    usb->ep_in = ep_in;
+    usb->ep_out = ep_out;
+    usb->zero_mask = zero_mask;
+    usb->writeable = 1;
+
+    adb_cond_init(&usb->notify, 0);
+    adb_mutex_init(&usb->lock, 0);
+    /* initialize mark to 1 so we don't get garbage collected after the device scan */
+    usb->mark = 1;
+    usb->reaper_thread = 0;
+
+    usb->desc = unix_open(usb->fname, O_RDWR);
+    if(usb->desc < 0) {
+        /* if we fail, see if have read-only access */
+        usb->desc = unix_open(usb->fname, O_RDONLY);
+        if(usb->desc < 0) goto fail;
+        usb->writeable = 0;
+        D("[ usb open read-only %s fd = %d]\n", usb->fname, usb->desc);
+    } else {
+        D("[ usb open %s fd = %d]\n", usb->fname, usb->desc);
+        n = ioctl(usb->desc, USBDEVFS_CLAIMINTERFACE, &interface);
+        if(n != 0) goto fail;
+    }
+
+        /* read the device's serial number */
+    serial[0] = 0;
+    memset(serial, 0, sizeof(serial));
+    if (serial_index) {
+        struct usbdevfs_ctrltransfer  ctrl;
+        __u16 buffer[128];
+        __u16 languages[128];
+        int i, result;
+        int languageCount = 0;
+
+        memset(languages, 0, sizeof(languages));
+        memset(&ctrl, 0, sizeof(ctrl));
+
+            // read list of supported languages
+        ctrl.bRequestType = USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE;
+        ctrl.bRequest = USB_REQ_GET_DESCRIPTOR;
+        ctrl.wValue = (USB_DT_STRING << 8) | 0;
+        ctrl.wIndex = 0;
+        ctrl.wLength = sizeof(languages);
+        ctrl.data = languages;
+
+        result = ioctl(usb->desc, USBDEVFS_CONTROL, &ctrl);
+        if (result > 0)
+            languageCount = (result - 2) / 2;
+
+        for (i = 1; i <= languageCount; i++) {
+            memset(buffer, 0, sizeof(buffer));
+            memset(&ctrl, 0, sizeof(ctrl));
+
+            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.wLength = sizeof(buffer);
+            ctrl.data = buffer;
+
+            result = ioctl(usb->desc, USBDEVFS_CONTROL, &ctrl);
+            if (result > 0) {
+                int i;
+                // 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] = 0;
+                break;
+            }
+        }
+    }
+
+        /* add to the end of the active handles */
+    adb_mutex_lock(&usb_lock);
+    usb->next = &handle_list;
+    usb->prev = handle_list.prev;
+    usb->prev->next = usb;
+    usb->next->prev = usb;
+    adb_mutex_unlock(&usb_lock);
+
+    register_usb_transport(usb, serial, usb->writeable);
+    return;
+
+fail:
+    D("[ usb open %s error=%d, err_str = %s]\n",
+        usb->fname,  errno, strerror(errno));
+    if(usb->desc >= 0) {
+        adb_close(usb->desc);
+    }
+    free(usb);
+}
+
+void* device_poll_thread(void* unused)
+{
+    D("Created device thread\n");
+    for(;;) {
+            /* XXX use inotify */
+        find_usb_device("/dev/bus/usb", register_device);
+        kick_disconnected_devices();
+        sleep(1);
+    }
+    return NULL;
+}
+
 static void sigalrm_handler(int signo)
 {
     // don't need to do anything here
@@ -460,15 +673,17 @@
 
 void usb_init()
 {
+    adb_thread_t tid;
     struct sigaction    actions;
 
-    if (usb_host_init(check_usb_device, kick_disconnected_device))
-        fatal_errno("usb_host_init failed\n");
-
     memset(&actions, 0, sizeof(actions));
     sigemptyset(&actions.sa_mask);
     actions.sa_flags = 0;
     actions.sa_handler = sigalrm_handler;
     sigaction(SIGALRM,& actions, NULL);
+
+    if(adb_thread_create(&tid, device_poll_thread, NULL)){
+        fatal_errno("cannot create input thread");
+    }
 }
 
