usbi_mutex_unlock(&ctx->open_devs_lock);
*handle = _handle;
- /* At this point, we want to interrupt any existing event handlers so
- * that they realise the addition of the new device's poll fd. One
- * example when this is desirable is if the user is running a separate
- * dedicated libusb events handling thread, which is running with a long
- * or infinite timeout. We want to interrupt that iteration of the loop,
- * so that it picks up the new fd, and then continues. */
- usbi_fd_notification(ctx);
+ if (usbi_backend->caps & USBI_CAP_HAS_POLLABLE_DEVICE_FD) {
+ /* At this point, we want to interrupt any existing event handlers so
+ * that they realise the addition of the new device's poll fd. One
+ * example when this is desirable is if the user is running a separate
+ * dedicated libusb events handling thread, which is running with a long
+ * or infinite timeout. We want to interrupt that iteration of the loop,
+ * so that it picks up the new fd, and then continues. */
+ usbi_fd_notification(ctx);
+ }
return 0;
}
/* Backend specific capabilities */
#define USBI_CAP_HAS_HID_ACCESS 0x00010000
#define USBI_CAP_SUPPORTS_DETACH_KERNEL_DRIVER 0x00020000
+#define USBI_CAP_HAS_POLLABLE_DEVICE_FD 0x00040000
/* Maximum number of bytes in a log line */
#define USBI_MAX_LOG_LEN 1024
const struct usbi_os_backend darwin_backend = {
.name = "Darwin",
- .caps = 0,
+ .caps = USBI_CAP_HAS_POLLABLE_DEVICE_FD,
.init = darwin_init,
.exit = darwin_exit,
.get_device_list = NULL, /* not needed */
const struct usbi_os_backend linux_usbfs_backend = {
.name = "Linux usbfs",
- .caps = USBI_CAP_HAS_HID_ACCESS|USBI_CAP_SUPPORTS_DETACH_KERNEL_DRIVER,
+ .caps = USBI_CAP_HAS_HID_ACCESS|USBI_CAP_SUPPORTS_DETACH_KERNEL_DRIVER|USBI_CAP_HAS_POLLABLE_DEVICE_FD,
.init = op_init,
.exit = op_exit,
.get_device_list = NULL,
const struct usbi_os_backend netbsd_backend = {
"Synchronous NetBSD backend",
- 0,
+ USBI_CAP_HAS_POLLABLE_DEVICE_FD,
NULL, /* init() */
NULL, /* exit() */
netbsd_get_device_list,
const struct usbi_os_backend openbsd_backend = {
"Synchronous OpenBSD backend",
- 0,
+ USBI_CAP_HAS_POLLABLE_DEVICE_FD,
NULL, /* init() */
NULL, /* exit() */
obsd_get_device_list,