From owner-freebsd-usb@FreeBSD.ORG Sun Jan 5 10:50:01 2014 Return-Path: Delivered-To: freebsd-usb@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 81EFA546 for ; Sun, 5 Jan 2014 10:50:01 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6C956148D for ; Sun, 5 Jan 2014 10:50:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id s05Ao1HA081605 for ; Sun, 5 Jan 2014 10:50:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id s05Ao1Od081604; Sun, 5 Jan 2014 10:50:01 GMT (envelope-from gnats) Date: Sun, 5 Jan 2014 10:50:01 GMT Message-Id: <201401051050.s05Ao1Od081604@freefall.freebsd.org> To: freebsd-usb@FreeBSD.org Cc: From: dfilter@FreeBSD.ORG (dfilter service) Subject: Re: usb/185454: commit references a PR X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list Reply-To: dfilter service List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Jan 2014 10:50:01 -0000 The following reply was made to PR usb/185454; it has been noted by GNATS. From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: usb/185454: commit references a PR Date: Sun, 5 Jan 2014 10:41:52 +0000 (UTC) Author: hselasky Date: Sun Jan 5 10:41:43 2014 New Revision: 260315 URL: http://svnweb.freebsd.org/changeset/base/260315 Log: Implement two new libusb API functions. PR: usb/185454 MFC after: 2 weeks Modified: head/lib/libusb/Makefile head/lib/libusb/libusb.3 head/lib/libusb/libusb.h head/lib/libusb/libusb10_io.c Modified: head/lib/libusb/Makefile ============================================================================== --- head/lib/libusb/Makefile Sun Jan 5 02:00:05 2014 (r260314) +++ head/lib/libusb/Makefile Sun Jan 5 10:41:43 2014 (r260315) @@ -130,6 +130,8 @@ MLINKS += libusb.3 libusb_event_handler_ MLINKS += libusb.3 libusb_lock_event_waiters.3 MLINKS += libusb.3 libusb_unlock_event_waiters.3 MLINKS += libusb.3 libusb_wait_for_event.3 +MLINKS += libusb.3 libusb_handle_events_timeout_completed.3 +MLINKS += libusb.3 libusb_handle_events_completed.3 MLINKS += libusb.3 libusb_handle_events_timeout.3 MLINKS += libusb.3 libusb_handle_events.3 MLINKS += libusb.3 libusb_handle_events_locked.3 Modified: head/lib/libusb/libusb.3 ============================================================================== --- head/lib/libusb/libusb.3 Sun Jan 5 02:00:05 2014 (r260314) +++ head/lib/libusb/libusb.3 Sun Jan 5 10:41:43 2014 (r260315) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 7, 2013 +.Dd January 5, 2014 .Dt LIBUSB 3 .Os .Sh NAME @@ -485,11 +485,40 @@ transfer completes or another thread sto timeout expired. .Pp .Ft int +.Fn libusb_handle_events_timeout_completed "libusb_context *ctx" "struct timeval *tv" "int *completed" +Handle any pending events by checking if timeouts have expired and by +checking the set of file descriptors for activity. +If the +.Fa completed +argument is not equal to NULL, this function will +loop until a transfer completion callback sets the variable pointed to +by the +.Fa completed +argument to non-zero. +If the +.Fa tv +argument is not equal to NULL, this function will return +LIBUSB_ERROR_TIMEOUT after the given timeout. +Returns 0 on success, or a LIBUSB_ERROR code on failure or timeout. +.Pp +.Ft int +.Fn libusb_handle_events_completed "libusb_context *ctx" "int *completed" +Handle any pending events by checking the set of file descriptors for activity. +If the +.Fa completed +argument is not equal to NULL, this function will +loop until a transfer completion callback sets the variable pointed to +by the +.Fa completed +argument to non-zero. +Returns 0 on success, or a LIBUSB_ERROR code on failure. +.Pp +.Ft int .Fn libusb_handle_events_timeout "libusb_context *ctx" "struct timeval *tv" Handle any pending events by checking if timeouts have expired and by checking the set of file descriptors for activity. Returns 0 on success, or a -LIBUSB_ERROR code on failure. +LIBUSB_ERROR code on failure or timeout. .Pp .Ft int .Fn libusb_handle_events "libusb_context *ctx" @@ -508,7 +537,7 @@ Must be called with the event lock held. Determine the next internal timeout that libusb needs to handle. Returns 0 if there are no pending timeouts, 1 if a timeout was returned, or a LIBUSB_ERROR -code on failure. +code on failure or timeout. .Pp .Ft void .Fn libusb_set_pollfd_notifiers "libusb_context *ctx" "libusb_pollfd_added_cb added_cb" "libusb_pollfd_removed_cb remove_cb" "void *user_data" Modified: head/lib/libusb/libusb.h ============================================================================== --- head/lib/libusb/libusb.h Sun Jan 5 02:00:05 2014 (r260314) +++ head/lib/libusb/libusb.h Sun Jan 5 10:41:43 2014 (r260315) @@ -438,6 +438,8 @@ int libusb_event_handler_active(libusb_c void libusb_lock_event_waiters(libusb_context * ctx); void libusb_unlock_event_waiters(libusb_context * ctx); int libusb_wait_for_event(libusb_context * ctx, struct timeval *tv); +int libusb_handle_events_timeout_completed(libusb_context * ctx, struct timeval *tv, int *completed); +int libusb_handle_events_completed(libusb_context * ctx, int *completed); int libusb_handle_events_timeout(libusb_context * ctx, struct timeval *tv); int libusb_handle_events(libusb_context * ctx); int libusb_handle_events_locked(libusb_context * ctx, struct timeval *tv); Modified: head/lib/libusb/libusb10_io.c ============================================================================== --- head/lib/libusb/libusb10_io.c Sun Jan 5 02:00:05 2014 (r260314) +++ head/lib/libusb/libusb10_io.c Sun Jan 5 10:41:43 2014 (r260315) @@ -336,29 +336,50 @@ libusb_wait_for_event(libusb_context *ct } int -libusb_handle_events_timeout(libusb_context *ctx, struct timeval *tv) +libusb_handle_events_timeout_completed(libusb_context *ctx, + struct timeval *tv, int *completed) { - int err; + int err = 0; ctx = GET_CONTEXT(ctx); - DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_timeout enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_timeout_completed enter"); libusb_lock_events(ctx); - err = libusb_handle_events_locked(ctx, tv); + while (1) { + if (completed != NULL) { + if (*completed != 0 || err != 0) + break; + } + err = libusb_handle_events_locked(ctx, tv); + if (completed == NULL) + break; + } libusb_unlock_events(ctx); - DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_timeout leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_timeout_completed exit"); return (err); } int +libusb_handle_events_completed(libusb_context *ctx, int *completed) +{ + return (libusb_handle_events_timeout_completed(ctx, NULL, completed)); +} + +int +libusb_handle_events_timeout(libusb_context *ctx, struct timeval *tv) +{ + return (libusb_handle_events_timeout_completed(ctx, tv, NULL)); +} + +int libusb_handle_events(libusb_context *ctx) { - return (libusb_handle_events_timeout(ctx, NULL)); + return (libusb_handle_events_timeout_completed(ctx, NULL, NULL)); } int @@ -371,8 +392,9 @@ libusb_handle_events_locked(libusb_conte if (libusb_event_handling_ok(ctx)) { err = libusb10_handle_events_sub(ctx, tv); } else { - libusb_wait_for_event(ctx, tv); - err = 0; + err = libusb_wait_for_event(ctx, tv); + if (err != 0) + err = LIBUSB_ERROR_TIMEOUT; } return (err); } _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"