- struct sr_context *ctx = data;
-
- while (ctx->usb_thread_running) {
- g_mutex_lock(&ctx->usb_mutex);
- libusb_wait_for_event(ctx->libusb_ctx, NULL);
- SetEvent(ctx->usb_event);
- g_mutex_unlock(&ctx->usb_mutex);
- g_thread_yield();
- }
-
- return NULL;
-}
-
-static int usb_callback(int fd, int revents, void *cb_data)
-{
- struct sr_context *ctx = cb_data;
- int ret;
-
- g_mutex_lock(&ctx->usb_mutex);
- ret = ctx->usb_cb(fd, revents, ctx->usb_cb_data);
-
- if (ctx->usb_thread_running) {
- ResetEvent(ctx->usb_event);
- g_mutex_unlock(&ctx->usb_mutex);
- }
-
- return ret;
+ libusb_close(usb->devhdl);
+ usb->devhdl = NULL;
+ sr_dbg("Closed USB device %d.%d.", usb->bus, usb->address);