From a805519ceedc53afa5453a6d8a7d80038d885d9f Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Mon, 19 Jul 2010 20:15:15 -0400 Subject: libusbhost: Add callback to usb_host_run to notify when initial device discovery is done This can be used to eliminate race conditions in clients that operate immediately on the currently connected device list. Signed-off-by: Mike Lockwood Change-Id: I14954b9fcc84239950ead6bdc1a0a888882c2226 --- libusbhost/usbhost.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libusbhost') diff --git a/libusbhost/usbhost.c b/libusbhost/usbhost.c index efd3103..f5ec140 100644 --- a/libusbhost/usbhost.c +++ b/libusbhost/usbhost.c @@ -144,6 +144,7 @@ void usb_host_cleanup(struct usb_host_context *context) void usb_host_run(struct usb_host_context *context, usb_device_added_cb added_cb, usb_device_removed_cb removed_cb, + usb_discovery_done_cb discovery_done_cb, void *client_data) { struct inotify_event* event; @@ -174,6 +175,8 @@ void usb_host_run(struct usb_host_context *context, /* check for existing devices first, after we have inotify set up */ done = find_existing_devices(added_cb, removed_cb, client_data); + if (discovery_done_cb) + done |= discovery_done_cb(client_data); while (!done) { ret = read(context->fd, event_buf, sizeof(event_buf)); -- cgit v1.1