| 536 | } |
| 537 | |
| 538 | static bool host_libusb_connectdevice(void) |
| 539 | { |
| 540 | int dev_cnt; |
| 541 | int i; |
| 542 | |
| 543 | dev_cnt = host_uninterruptible(libusb_get_device_list, |
| 544 | g_libusb_context, |
| 545 | &g_libusb_dev_list); |
| 546 | if (dev_cnt < 0) |
| 547 | { |
| 548 | ERROR("libusb_get_device_list() failed: %s\n", |
| 549 | host_uninterruptible(libusb_strerror, dev_cnt)); |
| 550 | return false; |
| 551 | } |
| 552 | |
| 553 | for (i = 0; i < dev_cnt; i++) |
| 554 | { |
| 555 | libusb_device *dev = g_libusb_dev_list[i]; |
| 556 | struct libusb_device_descriptor dev_desc; |
| 557 | int ret = host_uninterruptible(libusb_get_device_descriptor, |
| 558 | dev, &dev_desc); |
| 559 | if (ret != LIBUSB_SUCCESS) |
| 560 | { |
| 561 | ERROR("libusb_get_device_descriptor() failed: %s\n", |
| 562 | host_uninterruptible(libusb_strerror, ret)); |
| 563 | continue; |
| 564 | } |
| 565 | |
| 566 | if (dev_desc.bDeviceClass == LIBUSB_CLASS_HUB) |
| 567 | { |
| 568 | continue; |
| 569 | } |
| 570 | |
| 571 | if (dev_desc.idVendor == USB_VID || |
| 572 | dev_desc.idProduct == USB_PID) |
| 573 | { |
| 574 | g_libusb_dev.priv = dev; |
| 575 | memcpy(&g_libusb_dev.dev_desc, &dev_desc, |
| 576 | sizeof(struct libusb_device_descriptor)); |
| 577 | return true; |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | host_uninterruptible_no_return(libusb_free_device_list, |
| 582 | g_libusb_dev_list, 1); |
| 583 | g_libusb_dev_list = NULL; |
| 584 | return false; |
| 585 | } |
| 586 | |
| 587 | static int host_libusb_hotplug_callback(libusb_context *ctx, |
| 588 | libusb_device *device, |
no test coverage detected