From 59c62c7d744a9b5e4c7355932889cd0342044e09 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Wed, 2 Jul 2008 23:27:37 -0500 Subject: [PATCH] Update for libusb-0.9.1 --- configure.ac | 2 +- libfprint/core.c | 7 ++++--- libfprint/fp_internal.h | 1 + libfprint/poll.c | 14 +++++++------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index 386333b..9f29771 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ AC_SUBST(lt_major) AC_SUBST(lt_revision) AC_SUBST(lt_age) -PKG_CHECK_MODULES(LIBUSB, [libusb-1.0 = 0.9.0]) +PKG_CHECK_MODULES(LIBUSB, [libusb-1.0 >= 0.9.1]) AC_SUBST(LIBUSB_CFLAGS) AC_SUBST(LIBUSB_LIBS) diff --git a/libfprint/core.c b/libfprint/core.c index 2b57ca7..f9456c7 100644 --- a/libfprint/core.c +++ b/libfprint/core.c @@ -26,6 +26,7 @@ #include "fp_internal.h" +libusb_context *fpi_usb_ctx = NULL; GSList *opened_devices = NULL; /** @@ -426,7 +427,7 @@ API_EXPORTED struct fp_dscv_dev **fp_discover_devs(void) if (registered_drivers == NULL) return NULL; - r = libusb_get_device_list(&devs); + r = libusb_get_device_list(fpi_usb_ctx, &devs); if (r < 0) { fp_err("couldn't enumerate USB devices, error %d", r); return NULL; @@ -786,7 +787,7 @@ API_EXPORTED int fp_init(void) int r; fp_dbg(""); - r = libusb_init(); + r = libusb_init(&fpi_usb_ctx); if (r < 0) return r; @@ -822,6 +823,6 @@ API_EXPORTED void fp_exit(void) fpi_poll_exit(); g_slist_free(registered_drivers); registered_drivers = NULL; - libusb_exit(); + libusb_exit(fpi_usb_ctx); } diff --git a/libfprint/fp_internal.h b/libfprint/fp_internal.h index 7eb87f1..3d839bd 100644 --- a/libfprint/fp_internal.h +++ b/libfprint/fp_internal.h @@ -242,6 +242,7 @@ extern struct fp_img_driver aes4000_driver; extern struct fp_img_driver fdu2000_driver; extern struct fp_img_driver vcom5s_driver; +extern libusb_context *fpi_usb_ctx; extern GSList *opened_devices; void fpi_img_driver_setup(struct fp_img_driver *idriver); diff --git a/libfprint/poll.c b/libfprint/poll.c index 1c35741..a852905 100644 --- a/libfprint/poll.c +++ b/libfprint/poll.c @@ -228,7 +228,7 @@ API_EXPORTED int fp_handle_events_timeout(struct timeval *timeout) select_timeout = *timeout; } - r = libusb_handle_events_timeout(&select_timeout); + r = libusb_handle_events_timeout(fpi_usb_ctx, &select_timeout); *timeout = select_timeout; if (r < 0) return r; @@ -263,7 +263,7 @@ API_EXPORTED int fp_get_next_timeout(struct timeval *tv) int r_libusb; r_fprint = get_next_timeout_expiry(&fprint_timeout, NULL); - r_libusb = libusb_get_next_timeout(&libusb_timeout); + r_libusb = libusb_get_next_timeout(fpi_usb_ctx, &libusb_timeout); /* if we have no pending timeouts and the same is true for libusb, * indicate that we have no pending timouts */ @@ -297,7 +297,7 @@ API_EXPORTED size_t fp_get_pollfds(struct fp_pollfd **pollfds) size_t cnt = 0; size_t i = 0; - usbfds = libusb_get_pollfds(); + usbfds = libusb_get_pollfds(fpi_usb_ctx); if (!usbfds) { *pollfds = NULL; return -EIO; @@ -325,13 +325,13 @@ API_EXPORTED void fp_set_pollfd_notifiers(fp_pollfd_added_cb added_cb, fd_removed_cb = removed_cb; } -static void add_pollfd(int fd, short events) +static void add_pollfd(int fd, short events, void *user_data) { if (fd_added_cb) fd_added_cb(fd, events); } -static void remove_pollfd(int fd) +static void remove_pollfd(int fd, void *user_data) { if (fd_removed_cb) fd_removed_cb(fd); @@ -339,7 +339,7 @@ static void remove_pollfd(int fd) void fpi_poll_init(void) { - libusb_set_pollfd_notifiers(add_pollfd, remove_pollfd); + libusb_set_pollfd_notifiers(fpi_usb_ctx, add_pollfd, remove_pollfd, NULL); } void fpi_poll_exit(void) @@ -348,6 +348,6 @@ void fpi_poll_exit(void) active_timers = NULL; fd_added_cb = NULL; fd_removed_cb = NULL; - libusb_set_pollfd_notifiers(NULL, NULL); + libusb_set_pollfd_notifiers(fpi_usb_ctx, NULL, NULL, NULL); }