diff options
author | Chris Dickens <christopher.a.dickens@gmail.com> | 2015-01-21 00:18:43 -0800 |
---|---|---|
committer | Chris Dickens <christopher.a.dickens@gmail.com> | 2015-01-26 18:57:44 -0800 |
commit | 89f0316d38ec08836027bc88f30caab3768cedc5 (patch) | |
tree | 83a7df45992176447313d22f64dd8ad9d47bcd25 | |
parent | 4b716a2acb75f51eb652333d0bf7ea8e92b8e907 (diff) | |
download | libusb-89f0316d38ec08836027bc88f30caab3768cedc5.tar.gz |
openbsd: Transition to use new transfer completion API
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-rw-r--r-- | libusb/os/openbsd_usb.c | 79 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
2 files changed, 8 insertions, 73 deletions
diff --git a/libusb/os/openbsd_usb.c b/libusb/os/openbsd_usb.c index 1b96f34..2fc069d 100644 --- a/libusb/os/openbsd_usb.c +++ b/libusb/os/openbsd_usb.c @@ -41,7 +41,6 @@ struct device_priv { }; struct handle_priv { - int pipe[2]; /* for event notification */ int endpoints[USB_MAX_ENDPOINTS]; }; @@ -75,8 +74,7 @@ static void obsd_destroy_device(struct libusb_device *); static int obsd_submit_transfer(struct usbi_transfer *); static int obsd_cancel_transfer(struct usbi_transfer *); static void obsd_clear_transfer_priv(struct usbi_transfer *); -static int obsd_handle_events(struct libusb_context *ctx, struct pollfd *, - nfds_t, int); +static int obsd_handle_transfer_completion(struct usbi_transfer *); static int obsd_clock_gettime(int, struct timespec *); /* @@ -129,8 +127,8 @@ const struct usbi_os_backend openbsd_backend = { obsd_cancel_transfer, obsd_clear_transfer_priv, - obsd_handle_events, - NULL, /* handle_transfer_completion() */ + NULL, /* handle_events() */ + obsd_handle_transfer_completion, obsd_clock_gettime, sizeof(struct device_priv), @@ -264,10 +262,7 @@ obsd_open(struct libusb_device_handle *handle) usbi_dbg("open %s: fd %d", devnode, dpriv->fd); } - if (pipe(hpriv->pipe) < 0) - return _errno_to_libusb(errno); - - return usbi_add_pollfd(HANDLE_CTX(handle), hpriv->pipe[0], POLLIN); + return (LIBUSB_SUCCESS); } void @@ -282,11 +277,6 @@ obsd_close(struct libusb_device_handle *handle) close(dpriv->fd); dpriv->fd = -1; } - - usbi_remove_pollfd(HANDLE_CTX(handle), hpriv->pipe[0]); - - close(hpriv->pipe[0]); - close(hpriv->pipe[1]); } int @@ -517,8 +507,7 @@ obsd_submit_transfer(struct usbi_transfer *itransfer) if (err) return (err); - if (write(hpriv->pipe[1], &itransfer, sizeof(itransfer)) < 0) - return _errno_to_libusb(errno); + usbi_signal_transfer_completion(itransfer); return (LIBUSB_SUCCESS); } @@ -540,63 +529,9 @@ obsd_clear_transfer_priv(struct usbi_transfer *itransfer) } int -obsd_handle_events(struct libusb_context *ctx, struct pollfd *fds, nfds_t nfds, - int num_ready) +obsd_handle_transfer_completion(struct usbi_transfer *itransfer) { - struct libusb_device_handle *handle; - struct handle_priv *hpriv = NULL; - struct usbi_transfer *itransfer; - struct pollfd *pollfd; - int i, err = 0; - - usbi_dbg(""); - - pthread_mutex_lock(&ctx->open_devs_lock); - for (i = 0; i < nfds && num_ready > 0; i++) { - pollfd = &fds[i]; - - if (!pollfd->revents) - continue; - - hpriv = NULL; - num_ready--; - list_for_each_entry(handle, &ctx->open_devs, list, - struct libusb_device_handle) { - hpriv = (struct handle_priv *)handle->os_priv; - - if (hpriv->pipe[0] == pollfd->fd) - break; - - hpriv = NULL; - } - - if (NULL == hpriv) { - usbi_dbg("fd %d is not an event pipe!", pollfd->fd); - err = ENOENT; - break; - } - - if (pollfd->revents & POLLERR) { - usbi_remove_pollfd(HANDLE_CTX(handle), hpriv->pipe[0]); - usbi_handle_disconnect(handle); - continue; - } - - if (read(hpriv->pipe[0], &itransfer, sizeof(itransfer)) < 0) { - err = errno; - break; - } - - if ((err = usbi_handle_transfer_completion(itransfer, - LIBUSB_TRANSFER_COMPLETED))) - break; - } - pthread_mutex_unlock(&ctx->open_devs_lock); - - if (err) - return _errno_to_libusb(err); - - return (LIBUSB_SUCCESS); + return usbi_handle_transfer_completion(itransfer, LIBUSB_TRANSFER_COMPLETED); } int diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 5e0caf3..7a69b84 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10956 +#define LIBUSB_NANO 10957 |