| 774 | } |
| 775 | |
| 776 | int host_usbhost_init(void) |
| 777 | { |
| 778 | int ret; |
| 779 | |
| 780 | ret = host_uninterruptible(libusb_init, &g_libusb_context); |
| 781 | if (ret < 0) |
| 782 | { |
| 783 | ERROR("libusb_init() failed: %s\n", |
| 784 | host_uninterruptible(libusb_strerror, ret)); |
| 785 | return ret; |
| 786 | } |
| 787 | |
| 788 | ret = host_uninterruptible(libusb_hotplug_register_callback, |
| 789 | g_libusb_context, |
| 790 | (libusb_hotplug_event) (LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT | |
| 791 | LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED), |
| 792 | (libusb_hotplug_flag) 0, USB_VID, USB_PID, |
| 793 | LIBUSB_HOTPLUG_MATCH_ANY, host_libusb_hotplug_callback, |
| 794 | NULL, NULL); |
| 795 | if (ret != LIBUSB_SUCCESS) |
| 796 | { |
| 797 | ERROR("libusb_hotplug_register_callback() failed: %s\n", |
| 798 | host_uninterruptible(libusb_strerror, ret)); |
| 799 | return ret; |
| 800 | } |
| 801 | |
| 802 | g_libusb_dev.connected = host_libusb_connectdevice(); |
| 803 | |
| 804 | ret = host_uninterruptible(pthread_create, |
| 805 | &g_libusb_dev.handle_thread, |
| 806 | NULL, |
| 807 | host_libusb_event_handle, |
| 808 | NULL); |
| 809 | if (ret < 0) |
| 810 | { |
| 811 | ERROR("pthread_create() failed\n"); |
| 812 | return LIBUSB_ERROR_INVALID_PARAM; |
| 813 | } |
| 814 | |
| 815 | return LIBUSB_SUCCESS; |
| 816 | } |
no test coverage detected