History log of /external/libusb/libusb/io.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
88778414eac1cc6f37b85e6902d6fa2aa221b7c4 11-Aug-2016 Hans de Goede <hdegoede@redhat.com> core: Document why we drop the flying_transfers_lock before submit_transfer

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
9542c38cf2cbd911bd7e3ec161e564b3ae63d4fe 08-Jun-2016 Hans de Goede <hdegoede@redhat.com> core: Move calculate_timeout call to add_to_flying_transfers

This cleans-up libusb_submit_transfer a bit by avoiding an error
exit path with unlock calls.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
ce59e6ea12852f25025fef5ef42da9e271049a59 06-Jun-2016 Hans de Goede <hdegoede@redhat.com> core: Fix unlocked access to timeout_flags

There is a race between handle_timeout() and the completion functions.
When one thread is in handle_timeout() and another thread wakes
up from a poll(), there exists a window where the transfer has been
cancelled, but USBI_TRANSFER_TIMED_OUT is not yet set in timeout_flags.
Therefore, usbi_handle_transfer_completion() is sometimes called
with LIBUSB_TRANSFER_CANCELLED instead of the expected
LIBUSB_TRANSFER_TIMED_OUT.

timeout_flags is protected by the flying_transfers_lock, this commit
makes usbi_handle_transfer_cancellation() take that lock before
checking for USBI_TRANSFER_TIMED_OUT in timeout_flags, fixing this.

Reported-by: Joost Muller <joostmuller@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
d5a1418d9fbab126ded971d34eb8e27cfaa58b3d 06-Jun-2016 Hans de Goede <hdegoede@redhat.com> core: Test for LIBUSB_SUCCESS instead of 0 in handle_timeout()

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
06e86793be2efe098022fcba20be8624285132f1 06-Jun-2016 Hans de Goede <hdegoede@redhat.com> core: Do not arm timer-fd for transfers where the os handles timeout

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
138b661f4214e9fc10e836f3a8abebeb166da896 26-Oct-2015 Chris Dickens <christopher.a.dickens@gmail.com> core: Refactor code related to transfer flags and timeout handling

Commit a886bb02 sped up the library a bit by removing the serialization
of transfer submission with respect to the flying_transfers list, but
it introduced two separate issues.

1) A deadlock scenario is possible given the following sequence:

- Thread A submits transfer with very short timeout (say 1ms)
-> takes transfer->lock
-> adds transfer to flying_transfers list and arms timerfd
-> actually calls backend to submit transfer, but it fails
<context switch>
- Thread B is doing event handling and sees the timerfd trigger
-> takes ctx->flying_transfers_lock
-> finds the transfer above on the list
-> calls libusb_cancel_transfer() for this transfer
--> takes transfer->lock
<context switch>
- Thread A sees the transfer failed to submit
-> removes transfer from flying_transfers list
--> takes ctx->flying_transfers_lock (still holding transfer->lock)
** DEADLOCK **

2) The transfer state flags (e.g. submitting, in-flight) were protected
by transfer->flags_lock, but the timeout-related flags were OR'ed in
during timeout handling operations outside of the lock. This leads to
the possibility that transfer state might get overwritten.

This change corrects these issues and simplifies the transfer submission
code a bit by separating the state and timeout flags into their own flag
variables. The state flags are protected by the transfer lock. The timeout
flags are protected by the flying_transfers_lock.

The transfer submission code sheds some weight because it no longer needs
to worry about the timing of events that modify the transfer state flags.
These flags are always viewed and modified under the protection of the
transfer lock. Since libusb_submit_transfer() holds the transfer lock for
the entire duration of the operation, the other code paths that would
possibly touch the transfer (e.g. usbi_handle_disconnect() and
usbi_handle_transfer_completion()) have to wait for transfer submission
to fully complete. This eliminates any possible race conditions.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
[hdegoede@redhat.com: Reworked libusb_submit_transfer changes so that in
case both flying_transfer_lock and itransfer->lock are taken
flying_transfers_lock is always taken first]
[hdegoede@redhat.com: Removed some unrelated changes (will be submitted
as separate patches)]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
a5302ff86db391e6797a32693c242ddade5a09c2 26-Oct-2015 Chris Dickens <christopher.a.dickens@gmail.com> core: Change event handling lock to traditional (non-recursive) type

The event handling lock was previously required to be of the recursive
type because the libusb_close() path requires the lock and may be
called by a thread that is handling events (e.g. from within a
transfer or hotplug callback). With commit 960a6e75, it is possible to
determine whether the current function is being called from an event
handling context, thus the recursive lock type is no longer necessary.

References:
* http://libusb.org/ticket/82
* 74282582cc879f091ad1d847411337bc3fa78a2b
* c775c2f43037cd235b65410583179195e25f9c4a

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
[hdegoede@redhat.com: rebase on top of current master]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
2682e21d3d7e1e5ebd6dfe07f193efe48caa3e14 10-Aug-2016 Hans de Goede <hdegoede@redhat.com> Revert "io: Fix race condition in handle_timeout()"

This reverts commit bd8d5b5019b72b2dc2d074d96c9992e2f6e7e0b7.

Chris Dickens and me have been working on a patch-set refactoring
the transfer flag handling which fixes this differently. Revert
this commit so that the refactoring changes can be merged cleanly.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
bd8d5b5019b72b2dc2d074d96c9992e2f6e7e0b7 20-Jul-2016 Joost Muller <joostmuller@gmail.com> io: Fix race condition in handle_timeout()

There is a race between handle_timeout() the completion functions.
When one thread is in handle_timeout() and another thread wakes
up from a poll(), there exists a window where the transfer has been
cancelled, but its USBI_TRANSFER_TIMED_OUT flag is not set yet.
Therefore, usbi_handle_transfer_completion() is sometimes called
with LIBUSB_TRANSFER_CANCELLED instead of the expected
LIBUSB_TRANSFER_TIMED_OUT.

This change adds transfer and flag locks to the handle_timeout()
function.

Closes #197

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
/external/libusb/libusb/io.c
3a4fd0ac64cf9d4cf8f2a665f2f43f2bb1d25369 30-Jan-2016 Chris Dickens <christopher.a.dickens@gmail.com> core: Remove POSIX threads influence from synchronization code

This commit changes the signatures of the synchronization functions
to reflect the needs of the library rather than the signature of the
pthreads API. The mutex and condition variable attributes parameters
have been removed as no part of the core library makes use of them.

In addition, the condition variable timed-wait function has been modified
to accept the relative time passed in via libusb_wait_for_event(). This
allows the implementation-specific code to handle conversion to absolute
time as necessary, rather than forcing this to occur.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
b99391deb4894bbfff59fab985c99fc55a43169a 24-Feb-2016 Chris Dickens <christopher.a.dickens@gmail.com> Misc: Document the return code for control transfers that are too large

Closes #110

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
7ee92df12adb8015451aaecfeccd7dd62cc2314e 24-Feb-2016 Chris Dickens <christopher.a.dickens@gmail.com> Misc: Prefix doxygen references in order to namespace libusb

This change add "libusb_" to every group and page definition (and
updates all references accordingly) so that generated man pages
are namespaced for libusb, thus avoiding possible conflict with
other packages.

Closes #131

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
8a0c14372f98d56529556f18126a42fda2ab0137 24-Feb-2016 Chris Dickens <christopher.a.dickens@gmail.com> Misc: Make API parameter names consistent and sensible

Prior to this commit, API functions taking a libusb_device_handle
argument had the parameter named dev, handle, or dev_handle. This
commit changes the name of all libusb_device_handle parameters to
dev_handle in both the documentation and actual code.

Closes #132

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
16ddfe1ddc487d30c71420c9135f149751cf45d5 25-Sep-2015 Tobias Klauser <tklauser@distanz.ch> Misc: Spelling fixes

Fix spelling errors found by codespell, some of them in API
documentation and user visible messages.

Closes #102

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
a6db382ad11f7662b550338e0570d5a2dfd8ce5a 10-Dec-2015 Chris Dickens <christopher.a.dickens@gmail.com> API: Add libusb_interrupt_event_handler() function

This new function will allow the user to purposely interrupt an
event handling thread, causing it to return from the event handling
function. This is mainly useful for cleanly exiting from a dedicated
event handling thread during application shutdown.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
87a97e4f2065cc7190b0098b4d0df5a68e10a547 10-Dec-2015 Chris Dickens <christopher.a.dickens@gmail.com> core: Store different event types as a bitmask within the context

This change introduces a new event_flags member to the libusb_context
that holds a bitmask of different events that have occurred. This will
allow multiple "one-shot" events (those that don't require counting) to
be stored in a single variable. The only existing event of this type,
pollfds_modified, has been converted to use this bitmask instead.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
960a6e7506c4d0d59052056ae2ebfffbe8587175 10-Sep-2015 Chris Dickens <christopher.a.dickens@gmail.com> core: Prevent attempts to recursively hande events

Prior to this commit, it was possible to call certain functions from
within a hotplug or transfer completion callback that would in turn
attempt to handle events (e.g. any of the sync transfer APIs). This
is dangerous because certain events may cause the nested calls to
free memory that is currently in use by the previous calls.

This implementation uses thread-local storage to store a key within
the context that is set to a non-NULL value whenever event handling
is occurring. This allows us to detect when dangerous calls are made
from within event handling context. Such calls will return an error
code of LIBUSB_ERROR_BUSY.

Note that this implementation was chosen because of its portability.
It is supported on all platforms that libusb supports.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
a7e946aa1dcf51cfdada5732938e5d1ca18c749f 14-Apr-2015 Tobias Klauser <tklauser@distanz.ch> Miscellaneous fixes

* Use UNUSED macro instead of open coding it
* Use calloc to allocate and zero out buffers where appropriate
* Make unnecessarily global variables static
* Use strdup() instead of open-coding it
* Use passed fd in set_fd_cloexec_nb()
* Remove unused parameter from linux_device_disconnected()
* Closes #65

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
bf1635b3cb6cd8096f35fb1b0000d263522f191e 04-Sep-2015 Chris Dickens <christopher.a.dickens@gmail.com> io: Always complete transfers regardless of timerfd errors

This commit addresses two issues.

First, commit a886bb02 introduced an issue where transfer callbacks
would not be called if the transfer that completed was the first
in line and the timerfd needed to be armed for another transfer.

Second, failure to set the timerfd should not prevent the transfer
from completing. The behavior has always been such, but it will
leave clients waiting for their transfer callbacks to be called.
This change will let the transfer callback complete and will return
the error through the event handling path.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
2e1781e7c57384166e04d7728c42e45665d07b09 22-Aug-2015 Chris Dickens <christopher.a.dickens@gmail.com> core: Record when a transfer timeout has been handled

Commit efd02e73 introduced a bug where transfers that timed out
would be handled repeatedly if the cancellation was not successful.
This behavior blocks any event handling from occurring.

This commit adds a new transfer flag to record whether a timeout has
been handled.

Thanks to Jeffrey Nichols for reporting this.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
efd02e7348d9ac769235377b3d7395ecf1fdd0d9 03-Aug-2015 Chris Dickens <christopher.a.dickens@gmail.com> core: Correctly report cancellations due to timeouts

Prior to this commit, the handle_timeout() function would always
set the USBI_TRANSFER_TIMED_OUT flag on the transfer. However, in
some cases the actual cancellation of the transfer does not succeed,
perhaps because the transfer had just completed. This would cause
occasional false reporting of LIBUSB_TRANSFER_TIMED_OUT when the
transfer did not in fact timeout. This commit adds a check for
successful cancellation before setting the transfer flag.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
a4d2cb89b0c4f10f6c0cc02a2657cbaa94135470 01-Mar-2015 Chris Dickens <christopher.a.dickens@gmail.com> API: Add libusb_free_pollfds() function

This patch adds a new API call to ensure that the same memory
allocator is used to both allocate and free the list of libusb_pollfd
structures. It is an incorrect assumption that the user's free() will
use the same memory allocator that libusb uses internally.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
9b2c8abf134b96b6c1798615e0ed17991b8c0692 07-May-2015 Chris Dickens <christopher.a.dickens@gmail.com> core: Copy transfer timeout to local variable before using

The flying_transfers lock is taken in libusb_get_next_timeout()
to find the transfer with the next timeout, but the transfer was
being used outside of the lock, resulting in the possibility that
the transfer had been removed from the list and freed at the time
it was used.

Issue reported by Michel Sanches.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
02f7f859eec8aab0b680ad18d3aabd1fe24edb28 27-Apr-2015 Chris Dickens <christopher.a.dickens@gmail.com> core: Miscellaneous transfer timeout improvements

* When removing a transfer from the flying_transfers list, only
rearm the timerfd if the transfer being removed was the first
transfer *and* had a timeout. This is the only case where the
timerfd should be altered by a transfer being removed.

* When searching the flying_transfers list for the next timeout,
searching can cease when the first transfer with an infinite
timeout is encountered.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
0a5b00660b9558af05469321dfd2f8db8908911e 14-Apr-2015 Tobias Klauser <tklauser@distanz.ch> core: Remove unused member add_iso_packet_size from struct usbi_os_backend

The member add_iso_packet_size of struct usbi_os_backend is set to 0 in
all backends and thus has no actual use. This has been the case since
commit ad6e2b71 ("Linux: fire multiple URBs at once for split
transfers").

Also, the comment above the member actually states the fact that it is
unused and could potentially be removed, so remove it.

Closes #62

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
df08e7e290903ad851249a5ccf8ed1b0417282d8 16-Mar-2015 Matthias Bolte <matthias.bolte@googlemail.com> Misc: Remove unnecessary \n from log messages

The final end-of-line marker is added in usbi_log_v() using the
USBI_LOG_LINE_END define.

Also don't mix hardcoded \n and USBI_LOG_LINE_END in usbi_log_v().

Closes #59

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
a886bb02c87dd5faf271fad595e4622f7027d347 19-Jan-2015 Chris Dickens <christopher.a.dickens@gmail.com> core: Add internal transfer state management

This patch adds some new flags to keep track of transfer state.
These flags are used to properly handle transfers that are on
the flying_transfers list for devices that are disconnected.

The motivation for this patch is to release the requirement of
holding the flying_transfers_lock for the duration of a call to
libusb_submit_transfer(). Holding this lock is the simplest and
safest way to submit a transfer, but it has performance impacts
as it serializes transfer submission for a given context.

With proper transfer state management, the library can handle a
device disconnect without needing to prevent multiple transfers
from being concurrently submitted.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
e8dad7c37e0cdd7087be32073fb0a237cc18bd7b 21-Jan-2015 Chris Dickens <christopher.a.dickens@gmail.com> core: Implement new transfer completion API

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
51b10191033ca3a3819dcf46e1da2465b99497c2 22-Jan-2015 Chris Dickens <christopher.a.dickens@gmail.com> linux_usbfs: Update MAX_ISO_BUFFER_LENGTH

Newer kernels have raised the maximum length of individual ISO
packets and URBs. There's no easy way to detect the limit, so we
will define MAX_ISO_BUFFER_LENGTH as the largest known limit.

If a user runs this on an earlier kernel and submits an ISO transfer
that is too large, they will receive LIBUSB_ERROR_INVALID_PARAM.

The documentation has been updated to note this behavior, under
"Considerations for isochronous transfers".

Closes #23

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
859d6a961e11171ce06d2e5b761ec096a3d0bd26 08-Jan-2015 Chris Dickens <christopher.a.dickens@gmail.com> core: Fix handling of duplicate transfer submission/cancellation

In the docs, we claim to report LIBUSB_ERROR_BUSY if submitting a
transfer that has already been submitted. Linux was the only backend
that actually checked and reported this, but unfortunately the code
in libusb_submit_transfer() resulted in a segfault. This is because
submission failure would delete the (active) transfer from the
flying_transfers list, and when the transfer finally completes it
would be deleted from the flying_transfers list a second time.

Instead of modifying each backend to check for a busy transfer, this
patch adds a flag to indicate when a transfer is in-flight. The core
library will check this flag and return LIBUSB_ERROR_BUSY immediately.

This patch also modifies libusb_cancel_transfer() to check that a
transfer is in-flight before cancelling and to check that a transfer
has not already been cancelled, returning LIBUSB_ERROR_NOT_FOUND in
both cases.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
5ca334d653097a7320e44e671760552f98420756 08-Jan-2015 Chris Dickens <christopher.a.dickens@gmail.com> core: Add debug statements to help trace transfers

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
5e8928b8ca40b1dd33956c807a9bf745b7999852 06-Jan-2015 Chris Dickens <christopher.a.dickens@gmail.com> core: Make event_data_lock non-recursive

Hans pointed out that usbi_fd_notification() is only used by the
functions that add/remove pollfds. They already hold the required
lock, so to make it less expensive we will assume the lock is
already held.

The usbi_fd_notification() function has also been moved from core.c
into io.c and made static, since it now only has one use case.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
4c28cd8593cbbca234a1fa0b9b84f4356fd00796 21-Dec-2014 Chris Dickens <christopher.a.dickens@gmail.com> core: Improve the handling of the pollfd list

This change consists of two parts that must be taken together.

Part 1 moves the pollfd list under the protection of event_data_lock
and eliminates the pollfd_lock. Since modifications to the pollfd
list are considered an event, it makes sense to merge this. Another
benefit of doing so is an enhancement to event handling. The event
handler can get the updated pollfd list upon entry into handle_events()
and can clear the event pipe if no other pending events exist, which
saves a needless iteration.

Part 2 makes notification of pollfd list changes part of adding or
removing a pollfd from the list. Previously this was done in two
distinct steps, however nothing prevented a new pollfd from being
used by an event handler before an explicit notification was sent out.
This change eliminates the need for USBI_TRANSFER_UPDATED_FDS and
reverts 9a9ef3ec2b9c691609ec9f8b82ac4436a662df18.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
89b5407b9aa74790a64b6f32a5b14a96242ba128 18-Nov-2014 Chris Dickens <christopher.a.dickens@gmail.com> core: Signal the event pipe at most one time

This change will ensure that the event pipe is only signalled
at most one time during the course of any incoming events. New
events that occur while the event pipe is in the signalled state
will not cause the event pipe to be signalled again.

This change will provide support for the use of native events on
the Windows/WinCE backends, as these events are binary and do not
"count" the number of times they are signalled.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
3b371f1a6ab30bdebdadfcde1b96a9b98fb806ca 18-Nov-2014 Chris Dickens <christopher.a.dickens@gmail.com> core: Eliminate hotplug pipe, using list and event pipe instead

To further consolidate libusb internal events, this change removes
the hotplug pipe. Hotplug messages are now kept in a list within the
context, and the event pipe is signalled when a new hotplug message
is added. When handling events, the hotplug messages will be processed
from the list instead of from a separate pipe.

This change is greatly beneficial for the Windows/WinCE backends which
do not allow pipes to be used in the WaitFor* functions.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
192adf437baec398bec36de50737a570e6c2f29c 18-Nov-2014 Chris Dickens <christopher.a.dickens@gmail.com> core: Add helper functions to signal and clear the event pipe

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
5b2f2e11852edf81be401736e5ece7c9debe047e 18-Nov-2014 Chris Dickens <christopher.a.dickens@gmail.com> core: Rename pipe used to signal internal events

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
1b4b7f8b15fb98688a15c1125ede1e018a4451d6 18-Nov-2014 Chris Dickens <christopher.a.dickens@gmail.com> core: Transition device close event to use event_data_lock

This change removes the device_close_lock and uses the shared event
data lock to protect the value of the device_close counter.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
0e62e5cf34cd02e811157ecb4c6725f2b940a136 18-Nov-2014 Chris Dickens <christopher.a.dickens@gmail.com> core: Add new lock to protect internal context event data

This lock will be used in subsequent changes that will consolidate
all different event sources (i.e. device close, fd notification,
hotplug message) into a single event.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
c57953cfb3c8ecd4c51d34b7a2982713925530cd 18-Nov-2014 Chris Dickens <christopher.a.dickens@gmail.com> core: Rename pollfd_modify counter and its lock to device_close

This counter is now solely used for closing a device, so rename
the variable appropriately.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
7ede4b76bdfec18850d1c3bbe87af6a0f69f76dc 18-Nov-2014 Chris Dickens <christopher.a.dickens@gmail.com> core: Remove taking of events lock inside usbi_fd_notification()

It is unnecessary to take the events lock when a thread needs to
interrupt an event handler to receive a change list of poll fds.
It is sufficient to simply write to the control pipe and let the
event handler be notified of this event when it polls.

Taking the events lock inside this function leads to opportunity
for deadlock in certain situations, such as a client program
running on an OS that uses fd notification on each individual
transfer. If the client program were to protect a list of transfers
with a single lock, it could deadlock if that lock were taken in
two separate threads, one which is attempting to submit a new
transfer and one which is executing inside the transfer completion
callback.

Thanks to Dmitry Fleytman and Pavel Gurvich for reporting this.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
7e725e556a1a17f256878517c345e702f4a5858b 16-Dec-2014 Ludovic Rousseau <ludovic.rousseau@gmail.com> Doxygen: fix a duplicate label

libusb/io.c:46: warning: multiple use of section label 'intro' while
adding section, (first occurrence: libusb/core.c, line 79)

Use label "io_intro" instead of "intro"
/external/libusb/libusb/io.c
12e9e3557979af218ddb40f1e221d7fc56596fe9 30-Aug-2014 Chris Dickens <christopher.a.dickens@gmail.com> io: Move timerfd close into error handling path

This makes error handling consistent with other areas. This is a
follow-on change to commit b72f4cf77edb1975cada8aab5ae63361c68c5992.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
b72f4cf77edb1975cada8aab5ae63361c68c5992 27-Aug-2014 Chris Dickens <christopher.a.dickens@gmail.com> io: Fix memory leaks in usbi_io_init()

* If the hotplug pipe failed to be created, the usbi_pollfd for the
control pipe was being leaked.
* If the usbi_pollfd for timerfd failed to be added, the usbi_pollfd
for the hotplug pipe was being leaked.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
d8a2950f5409ee399c386b56301d49c61ee71fdf 03-Sep-2014 Chris Dickens <christopher.a.dickens@gmail.com> core: Make use of headers consistent across all files

* Include config.h before anything else in all files
* Remove unnecessary inclusion of libusb.h
* Use angle brackets for system headers and quotes for local headers

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
3c323dc36e0d7c77dba4c189c1815bf0f7e616bb 30-Aug-2014 Chris Dickens <chris.dickens@hp.com> core: Rename count variable for pollfds for consistency with other count variables

Signed-off-by: Chris Dickens <chris.dickens@hp.com>
/external/libusb/libusb/io.c
8c60a6716d7ff3bb4a9e13a9b89ee5622e4fde7f 05-Jun-2014 Chris Dickens <christopher.a.dickens@gmail.com> core: Reuse poll fds across calls to handle_events()

Prior to this patch, the array of poll fds given to poll() was
allocated and freed every time handle_events() was called. This
is unnecessary if the list of poll fds has not changed since the
last call to handle_events(). With this patch, the array and count
of poll fds is stored in the context and only reallocated when the
list of poll fds changes, saving any unnecessary overhead.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
b5f43b29e77f4bc867146acf1f6f18c3f4ad71b5 26-Aug-2014 Chris Dickens <christopher.a.dickens@gmail.com> core: Be more efficient by not passing internal fds to backend

There are a number of fds that the core uses internally. Currently
any events on these fds are masked out so that the backend will
skip over them during handle_events().

This change improves upon this by simply not providing these fds
to the backend.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
a3a4806d494b8ff3dd213d5eb408b657bcdd47f0 26-Aug-2014 Chris Dickens <christopher.a.dickens@gmail.com> usbi_handle_transfer_completion: Remove signal to event waiters

usbi_handle_transfer_completion() is only called by backends when
handling transfer completion. The backend can only make this call
whilst holding the events lock, therefore it is pointless to send
this signal. Any threads waiting to be signaled will be woken up
and will either find that an event handler is still active or will
try to obtain the events lock and be blocked.

Event waiters are automatically signaled in libusb_unlock_events(),
so when the backend is done handling events it will release the lock
and wake up any waiters. At this point the events lock wll be free,
which is the only time waking up waiters makes sense.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
/external/libusb/libusb/io.c
6edd96ab818fab9a35efa385b489b9a56ca91dbc 30-May-2014 Hans de Goede <hdegoede@redhat.com> libusb_submit_transfer: Don't reference the device on submission failure

If submission fails libusb_ref_device will never get balanced by an unref
on completion, since there will be no completion.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
4f347f01fa2745b7d00e6e336726c9a329bd6fbb 30-May-2014 Hans de Goede <hdegoede@redhat.com> libusb_submit_transfer: Fix possible deadlock

Fix a possible deadlock due to a lock ordering reversal, caught by Coverity:

*** CID 62579: Thread deadlock (ORDER_REVERSAL)
/libusb/io.c: 1451 in libusb_submit_transfer()
1445 r = calculate_timeout(itransfer);
1446 if (r < 0) {
1447 r = LIBUSB_ERROR_OTHER;
1448 goto out;
1449 }
1450
>>> CID 62579: Thread deadlock (ORDER_REVERSAL)
>>> Calling "pthread_mutex_lock" acquires lock "libusb_context.flying_transfers_lock" while holding lock "usbi_transfer.lock" (count: 1 / 4).
1451 usbi_mutex_lock(&ctx->flying_transfers_lock);
1452 r = add_to_flying_list(itransfer);
1453 if (r == LIBUSB_SUCCESS) {
1454 r = usbi_backend->submit_transfer(itransfer);
1455 }
1456 if (r != LIBUSB_SUCCESS) {

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
6d8dfe0aee41a3c7dd862c3de488df3ce452d86e 11-Sep-2013 Hans de Goede <hdegoede@redhat.com> Add API for using bulk streams

Being able to allocate bulk-streams is not really useful if the user cannot
specify the stream ids when submitting transfers.

The actual stream id gets added to our private itransfer struct, and a setter +
getter are added to get to it. Unfortunately this is the only way to add
support for stream ids without breaking ABI. So this is another item to fix
when we do break ABI in libusb-2.0.

Bulk streams also use a separate transer type, to allow backends to determine
if a transfer is a bulk stream transfer or an ordinary bulk transfer. This is
added because there is no other reliable way to determine if a transfer is
a stream as the stream_id is part of the private itransfer struct so apps
re-using a transfer may not set it to 0. Adding a separate transfer-type
for this was suggested (and coded) by Nathan Hjelm.

Most users will likely use the new libusb_fill_bulk_stream_transfer()
though, and will never know the difference.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
7e076fe9f519cbf12f55bb143a56ebed4a26d599 21-Mar-2014 Sean McBride <sean@rogue-research.com> Removed empty \see statements, fixing -Wdocumentation warnings
/external/libusb/libusb/io.c
1eff220474f63d7ea7f8f99bef2a3da9da5324eb 09-Jan-2014 hjelmn@cs.unm.edu <hjelmn@cs.unm.edu> Misc: Revert all references to libusb/libusb.info
/external/libusb/libusb/io.c
359a273b36d810e0fda4117a3131116350db822b 15-Oct-2013 Hans de Goede <hdegoede@redhat.com> io: Ensure all pending events are consumed in one libusb_handle_events call

Before this patch if ie multiple hot-plug events were pending, multiple
handle_events calls would be necessary to handle them all, this patch
changes handle_events so that the poll is re-done to check for more events
if there was activity on any of the special fds.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
c089900c486e94b067e4d30ef9047a80cbb6d689 01-Jul-2013 Paul Fertser <fercerpav@gmail.com> Clarify alignment requirements for the control transfer buffer

Since the buffer pointer will later be casted to ``struct
libusb_control_setup *'', it should point to memory aligned to at least
2 bytes boundary as that's the strictest requirement of the struct fields.

Also, use a (void *) casting trick to convince the compiler the cast is
safe, to fix warnings such as:

/usr/local/include/libusb-1.0/libusb.h: In function 'libusb_control_transfer_get_setup':
/usr/local/include/libusb-1.0/libusb.h:1435:9: error: cast increases required alignment of target type [-Werror=cast-align]
/usr/local/include/libusb-1.0/libusb.h: In function 'libusb_fill_control_setup':
/usr/local/include/libusb-1.0/libusb.h:1464:39: error: cast increases required alignment of target type [-Werror=cast-align]
/usr/local/include/libusb-1.0/libusb.h: In function 'libusb_fill_control_transfer':
/usr/local/include/libusb-1.0/libusb.h:1509:39: error: cast increases required alignment of target type [-Werror=cast-align]
cc1: all warnings being treated as errors

This actually can lead to failure to build from the sources for certain
projects which use -Werror=cast-align on ARM.

Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
c848e5b72a1670a33eb84f210b951177a3de19e9 06-Aug-2013 Chris Dickens <christopher.a.dickens@gmail.com> Core: Fix potential segfault caused by using freed memory

When a transfer is submitted, the device is referenced in libusb_submit_transfer()
and unreferenced in usbi_handle_transfer_completion(). This transfer could potentially
be freed by any user callback, or is freed by libusb if LIBUSB_TRANSFER_FREE_TRANSFER
is set in the flags. The call to unreference the device uses this potentially freed
memory. Reading the device handle beforehand will prevent this disaster.
/external/libusb/libusb/io.c
7dad81fe6167c7dc903f88f3d1878a2f65b91710 02-Aug-2013 Chris Dickens <christopher.a.dickens@gmail.com> Core: correctly check usbi_read() returned value

For messages received on the hotplug pipe, the message was read via
usbi_read() (ssize_t) and compared against the size of the message
struct (size_t). usbi_read() returns -1 on an error condition, so some
systems can cast the ssize_t to size_t for the comparison, making it
equal to SIZE_MAX and causing the error check condition to incorrectly
evaluate to false.
/external/libusb/libusb/io.c
707d500b9fea002f075cf30458a602f28dbd1348 24-Jul-2013 Nathan Hjelm <hjelmn@me.com> keep a reference to the device for each active transfer and let the backend handle cancelling active transfers when a device is disconnected

This commit should fix issues with active transfers when a device is
disconnected. The backend is responsible for making sure the completion
callbacks are made, not the hotplug code. This should fix a number of
issues including duplicate callbacks and segmentation faults.

References #124.
/external/libusb/libusb/io.c
ef59b06f4addfa9a5413b058cfb4f674df447411 05-Jul-2013 Hans de Goede <hdegoede@redhat.com> Documentation: add an Using an event handling thread section

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
230b9a0105fd81dbeacec42715285651df3a3591 05-Jul-2013 Hans de Goede <hdegoede@redhat.com> Documentation: explain the 2 main viable event handling approaches

Stop pretending that having a separate event handling thread is a bad thing,
specifically delete the "[this] option is not very nice either, but may be
the nicest option available to you if the "proper" approach can not be applied
to your application", which suggests that using poll integration into a main
loop is the one and only "proper" approach.

Instead clearly document there are 2 viable approaches, using a separate
thread, or poll integration into a main loop.

Also stop claiming that libusb does not use threads internally, as with
the new hotplug support this is no longer true.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
f50592979811a00d52305ea02b420cb9cacc99b4 04-Jul-2013 Hans de Goede <hdegoede@redhat.com> hotplug: Give the usbi_hotplug_match* functions a context parameter

So that the device parameter can be NULL, in combination with a 0
events parameter, to be used to force lazy deregistration.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
51655d74909fca03209cb5de5b90fb8d4e7dc465 24-May-2013 Toby Gray <toby.gray@realvnc.com> POSIX: Move setting of pipes to non-blocking into usbi_pipe

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
fa27f99772e9200d97518fe2aa7332e892949132 17-May-2013 Hans de Goede <hdegoede@redhat.com> core: Fix handle_events return code on hotplug pipe read error

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
858b794cf10ff1ac76a4f453bed7645aa9709c44 03-May-2013 Hans de Goede <hdegoede@redhat.com> usbi_handle_disconnect: Fix race condition leading to double completion

It took me quite a while to debug this, here is a step by step for the race
which I believe is happening in some cases:

1) app calls libusb_submit_transfer
2) libusb_submit_transfer locks itransfer->lock
3) libusb_submit_transfer adds the transfer to the flying list
4) *thread switch*
5) other thread notices POLL_ERR on device fd, calls usbi_handle_disconnect
6) usbi_handle_disconnect find the transfer which is in progress of being
submitted in the flying list
7) usbi_handle_disconnect calls usbi_backend->clear_transfer_priv on the
transfer, this blocks waiting on itransfer->lock
8) *thread switch*
9) libusb_submit_transfer actually tries to submit the transfer now,
calls usbi_backend->submit_transfer, which fails with -ENODEV
10) libusb_submit_transfer *removes* the transfer from the flying list,
unlocks itransfer->lock and returns an error to its caller
11) the caller frees the transfer, meaning the to_cancel pointer in
usbi_handle_disconnect now points to free-ed memory, for extra mayhem
12) *thread switch*
13) usbi_handle_disconnect calls usbi_handle_transfer_completion
14) usbi_handle_transfer_completion tries to remove the transfer from
the flying list *for the 2nd time*
But the first call done from libusb_submit_transfer has already done
this. libusb's list_del looks like this:

static inline void list_del(struct list_head *entry)
{
entry->next->prev = entry->prev;
entry->prev->next = entry->next;
entry->next = entry->prev = NULL;
}

So the first call sets it next and prev to NULL, and then the 2nd call
tries to deref next -> BOOM

For an example backtrace caused by this, see:
https://bugs.freedesktop.org/show_bug.cgi?id=55619#c7

This patch fixes this by letting libusb_submit keep the flying transfers list
locked during submission, so the submission flow changes from:

1) lock flying transfers
add to flying transfers
unlock
2) submit
3) on submission error:
lock flying transfers
remove from flying transfers
unlock

to:

1) lock flying transfers
2) add to flying transfers
3) submit
4) on submission error:
remove from flying transfers
5) unlock

This means that the os backends submit handler now gets called with the
flying transfers lock held! I've looked at all the backends and this should
not be a problem. Only the windows and win-ce backends care about the
flying transfers list at all, and then only in their handle_events handler.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
84d53288970f0d72d43629a8125b332bcebdc8b0 03-May-2013 Hans de Goede <hdegoede@redhat.com> usbi_handle_disconnect: Add some debugging wrt cancelled transfers

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
c235fa2f9d90b6f65f75c545e90596545879ca4f 16-May-2013 Hans de Goede <hdegoede@redhat.com> core: Improve error / debug messages for hotplug pipe handling

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
57256dd1597c9b8641bef1596edbeddc4348dd86 15-May-2013 Nathan Hjelm <hjelmn@me.com> Add some editor meta-comments for proper tab usage

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
7801ff94fa6e49fe98433eccc7f2e461590a6f7c 29-Nov-2012 Nathan Hjelm <hjelmn@me.com> Add hotplug support.

The internal API is changing as follows:
- Adding two new functions. usbi_connect_device, and usbi_disconnect_device.
Backends must call these functions to add them to the context's device list
at one of two places: initial enumeration (done at init), and on device
attach and removal. These functions need to be called once per context.
- Backends that support hotplug should not provide a get_device_list funtion.
This function is now deprecated and will likely be removed once all backends
support hotplug.

The external API is changing as follows:
- Two new functions have been added to register and deregister callbacks for
hotplug notification: libusb_hotplug_register_callback(),
libusb_hotplug_deregister_callback(). Hotplug callbacks are called by
libusb_handle_events(). Details of the new API can be found in libusb.h.
- A new capability check has been added to check for hotplug support. See
LIBUSB_CAP_HAS_HOTPLUG.

Aa suggested by Xiaofan add new example has been added to show how to use
the new external hotplug API. See examples/hotplugtest.c.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
0ded9c126e9b48b5ed217e60d392cfb882cbc351 27-Feb-2013 Pete Batard <pete@akeo.ie> Misc: Simplify includes and misc. cleanup

* fxload sample provenance
* No need for <sys/types.h> in samples as already in libusb.h
* Don't bother about sscanf_s in xusb
* Use HAVE_### and rely on config.h where possible
* Formal inclusion of <winsock.h> in libusb.h for WinCE and WDK
* Cleanup of Windows' config.h
* Avoid ENAMETOOLONG and ENOTEMPTY conflict between errno.h and winsock.h for WinCE
* Additional newlines & braces cleanup
/external/libusb/libusb/io.c
bfd02c6f59f11a6af8cc9e6af96f4942cc37a5f4 13-Oct-2012 Ludovic Rousseau <ludovic.rousseau@gmail.com> Core: Fix compiler warning

libusb/io.c:1877:35: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
timeout_ms = (tv->tv_sec * 1000) + (tv->tv_usec / 1000);
~ ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

On Mac OS X tv_sec is a __darwin_time_t which is a long, not an int.
/external/libusb/libusb/io.c
e39b24ae5a6069b1571ecef3eb510c9e90db4956 31-Oct-2012 Sean McBride <sean@rogue-research.com> Use "" instead of <> for internal includes

some libusbx include files were included with angle brackets, changed to
quotes. Needed to work better in Xcode project
/external/libusb/libusb/io.c
6a445e6a0c07d05475cbb20632dba9297e372b43 26-Oct-2012 Ludovic Rousseau <ludovic.rousseau@gmail.com> Core: Fix warning implicit conversion changes signedness

* Closes #70
/external/libusb/libusb/io.c
1e6928ccab25f933950ab67f9dba30cdc8822056 15-Jan-2013 Pete Batard <pete@akeo.ie> Core: Use HAVE_SYS_TYPES_H and HAVE_SIGNAL_H

* These files may not be available on all platforms (eg. WinCE)
/external/libusb/libusb/io.c
00a3cf9630d8376ba0c1351d30da06dc9a5f8660 12-Sep-2012 Hans de Goede <hdegoede@redhat.com> All: Avoid polluting errors reported on device disconnect

* Makes libusb_cancel_transfer not log an error when the cancel fails
with LIBUSB_ERROR_NO_DEVICE, so that apps can properly clean things
up on device disconnect without flooding the console with these errors.
* Also, some devices (Cypress FX) may switch VID:PID on the fly during
firmware upload => reduce severity of the Windows message when that happens.
/external/libusb/libusb/io.c
01f31ebe1ebfa552980750a1f3d2847819dea25a 22-Aug-2012 Peter Stuge <peter@stuge.se> Core: Handle >= 1 second transfer timeout in libusb_submit_transfer()

* Comparisons between tv_nsec and 1 sec should be >= rather than >,
as we can end up in situations where tv_nsec is exactly 1000000000,
which calls such as timerfd_create() do not accept.
* Issue reported by Sebastian K. See:
https://sourceforge.net/mailarchive/message.php?msg_id=29706972
/external/libusb/libusb/io.c
de56675c99f8f7b0b13a08dfe6a076bfdff928d0 12-Aug-2012 Pete Batard <pete@akeo.ie> Core: Improve instrumentation of timerfd_settime failures

* Report errno as well as itimerspec data
* Also reuse the timeout variable set to &transfer->timeout
/external/libusb/libusb/io.c
3fadb8b4facf5106f1127e389e1855013c1701ca 10-Jul-2012 Pete Batard <pete@akeo.ie> Core: Fix unconditional disarming of timerfd

* Existing code appears disarms the timerfd always, which cancels
pending timeouts as soon as one packet completes.
* This fix moves the disarming of the timerfd to
arm_timerfd_for_next_timeout(), where it is now done conditionally.
It also avoids calling disarm outside of the above call.
* This patch also ensures that all handling of the timerfd is done
under the flying transfers lock.
* Issue reported by Hans de Goede. For more info, see:
https://sourceforge.net/mailarchive/message.php?msg_id=29442693
/external/libusb/libusb/io.c
1572419e943e80883da9341ca65703124938c3d8 11-Jul-2012 Davidlohr Bueso <dave@gnu.org> All: Replace malloc+memset with calloc
/external/libusb/libusb/io.c
21ce67310216dd1173a582b584399bf6096965ea 13-Jun-2012 Pete Batard <pete@akeo.ie> Core: Fix Clang warnings

core.c:
* Result of 'malloc' is converted to a pointer of type 'struct libusb_device *',
which is incompatible with sizeof operand type 'void *'
* Memory is never released; potential leak of memory pointed to by 'devs'
* Assigned value is garbage or undefined (due to potentially empty and
uninitialized device list)
descriptor.c:
* Function call argument is an uninitialized value
io.c:
* Call to 'malloc' has an allocation size of 0 bytes
* Branch condition evaluates to a garbage value (due to get_next_timeout
returning a negative error code instead of zero on error)
/external/libusb/libusb/io.c
a544e5972bf2b0ac9e006439576f681a8439d311 23-May-2012 Pete Batard <pete@akeo.ie> Misc: Ensure all sources are UTF-8

* Also remove extra lines at the end of samples
/external/libusb/libusb/io.c
1ed09c7b2a5fc27c3cfea21740584879781bff67 03-May-2012 Toby Gray <toby.gray@realvnc.com> Windows: Fix deadlock in backend when submitting transfers.

Without this change the Windows backend needed to call usbi_fd_notification()
from within the backend's submit_transfer. This can cause deadlock when
attempting to lock the event lock if another thread was processing events on
the just-submitted transfer.

The deadlock comes about as the thread calling libusb_submit_transfer acquires
the transfer mutex before trying to acquire the event lock; this is the other
order of lock acquisition from an event thread handling activity on the just
submitted transfer. This could lead to one of two deadlocks:

1) If the transfer completes while usbi_fd_notification() is waiting for
the event lock and the callback attempts to resubmit the transfer.

2) If the transfer timeout is hit while usbi_fd_notification() is waiting
for the event lock then the attempt to cancel the transfer will deadlock.

This patch fixes both of these deadlocks by having libusb_submit_transfer()
only call usbi_fd_notification() after having released the transfer mutex.
/external/libusb/libusb/io.c
16b7adcab9b45c9e53e15607f45717272b9a164b 16-Apr-2012 Peter Stuge <peter@stuge.se> Core: Add debug message with callback address on completed transfer
/external/libusb/libusb/io.c
b49cfaec7806719ce7787c20a7574007488d26a3 03-Apr-2012 Pete Batard <pete@akeo.ie> Misc: Fix missing libsub's -> libusbx's from previous patches
/external/libusb/libusb/io.c
791b7473ec38155ee3d1d9889f3d0f1b4c8f33f0 03-Apr-2012 Pete Batard <pete@akeo.ie> Misc: Rebrand to libusbx

* Mentions of 'libusb' in doxygen are changed to 'libusbx'
* Also update copyright notices and remove unneeded EOF LFs
/external/libusb/libusb/io.c
f18a081dd742f332511101a5dc715bd6b16cb92a 26-Mar-2012 Hans de Goede <hdegoede@redhat.com> Linux: Don't print errors when cancel_transfer fails with NOT_FOUND

* Under some cricumstances, LIBUSB_ERROR_NOT_FOUND is an expected
return value for cancel_transfer so printing an error is undesirable.
/external/libusb/libusb/io.c
e3d0a4cb9e2f9872c9fdbb22d7ded169e111fc8f 22-Feb-2012 Peter Stuge <peter@stuge.se> Add LIBUSB_TRANSFER_ADD_ZERO_PACKET flag to indicate need for ZLP

Some protocols which use USB require an extra zero length data packet
to signal end-of-transfer on bulk endpoints, if the last data packet
is exactly wMaxPacketSize bytes long.

This flag allows applications to inform libusb about this requirement,
so that libusb can handle the issue transparently.

At the moment the new flag is only supported on Linux, and submitting
a transfer with the flag set returns an error at submit time on other
systems. Hopefully implementations will soon follow for other systems.

References #6.
/external/libusb/libusb/io.c
4630fc22cff8ad3e1afa9b223378c0aabe282b5c 13-Feb-2012 Peter Stuge <peter@stuge.se> Do not call timerfd functions when timerfd is not being used

When libusb was built with timerfd support but used on a system
without timerfd support the library would hang indefinitely on
completion of the first transfer, since timerfd functions were
being called unconditionally and the error returned when timerfd
was not being used caused a confused internal state.

Many thanks to Ivo Smits for looking into the issue, proposing
an initial solution, and helping with testing! Fixes #73.
/external/libusb/libusb/io.c
fa66c93253855c9146011a6854d65df6d390039f 14-Dec-2011 Pete Batard <pbatard@gmail.com> Windows: Output an error message on calls to libusb_get_pollfds()

Signed-off-by: Michael Plante <michael.plante@gmail.com>
/external/libusb/libusb/io.c
637145ed29ee7c7b13ac45d10cf1f798fc06cbd9 04-Jun-2010 Pete Batard <pbatard@gmail.com> io.c: Fix comment since pthreads isn't the only threading libusb uses
/external/libusb/libusb/io.c
59cc79f2c8e5da41fe2c761bf1e1d9cd18ddac81 19-Sep-2011 Sean McBride <sean@rogue-research.com> Fix unused variable warnings when without timerfd and/or when on Darwin

References #121.
/external/libusb/libusb/io.c
9ad3643391a7fc6ce97aa77ffaf97d244fd9e613 14-Sep-2011 Hans de Goede <hdegoede@redhat.com> Docs: Clarify that libusb_handle_events_timeout() tv param can't be NULL

The example code and API doc for libusb_handle_events_timeout() could be
interpreted as it being OK to pass a NULL pointer for the tv argument (I
interpreted it like that when I first started coding for libusb).

This patch changes the docs to make it clear that one must always supply
a tv struct to libusb_handle_events_timeout.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/external/libusb/libusb/io.c
2dc2fa2a56408e515d25359323b4ea2f1bbec14a 13-Sep-2011 Sebastian Pipping <sebastian@pipping.org> Fix typos in introductory documentation
/external/libusb/libusb/io.c
f797ecb3b4e653594f8ebc0c9d9e2ca579062779 12-Sep-2011 Hans de Goede <hdegoede@redhat.com> Document libusb_handle_events_completed() and _timeout_completed()

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
[stuge: Note that the old racy functions should be avoided by new code]
/external/libusb/libusb/io.c
6696512aade99bb15d6792af90ae329af270eba6 10-Sep-2011 Graeme Gill <graeme2@argyllcms.com> Fix #56 race condition causing delayed completion of sync transfers

The sync API had a race where it would check a condition to know if it
needed to call a libusb_handle_events() function. However, the check
was done outside of the lock that is held while the condition is set,
so another thread could completely serve whatever was needed to make
the condition true between it being checked and the event handler being
called. This situation would be detected after a libusb-internal timeout
of 60 seconds, after which the transfer would be completed without
error, but with significant delay.

Original patch at http://marc.info/?l=libusb-devel&m=127252114815709

Changes by Hans de Goede:
- Renamed the "race-proof" functions from libusb_handle_events*_check()
to libusb_handle_events*_completed()
- Drop r = 0 setting in libusb_handle_events_timeout_completed()
(to make both completed checking cases identical flow wise)

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
[stuge: Simplify libusb_handle_events_timeout() change with a goto]
[pbatard: Fix _handle_events_timeout() and _completed() definitions]
/external/libusb/libusb/io.c
d1bd234f7e1b1ff4168b8f605e2038e87a0e361f 22-Jul-2011 Nathan Hjelm <hjelmn@me.com> Fix #64 use of reserved identifiers throughout libusb
/external/libusb/libusb/io.c
c775c2f43037cd235b65410583179195e25f9c4a 17-Mar-2011 Vitali Lovich <vlovich@aliph.com> Clean up in-flight transfers and device handle when closing a device

Any in-flight transfers should properly invalidate their references
to device handles that are being closed. Additionally, they should be
removed from the transfer-in-flight list. This is done with the events
lock held to protect against another thread processing the same transfer.
The events lock is initialized as a recursive mutex, because the device
close code might itself be called while an event is being handled.
Fixes #82.

[stuge: Trivial rework to reduce indenting]
/external/libusb/libusb/io.c
8f1bc0659136faf312dabe8fe67380a798299d33 17-Mar-2011 Vitali Lovich <vlovich@aliph.com> Add USBI_TRANSFER_CANCELLING and _DEVICE_DISAPPEARED status flags

The flags are used to indicate if a cancellation has started, and if
a cancellation has failed because the device is no longer available.
References #82.
/external/libusb/libusb/io.c
b67120f047f7eafa15c88c66fa61cef40805ec1f 05-Feb-2010 Sean McBride <sean@rogue-research.com> io.c: Fix clang analyzer warning about unused variable

References #28.
/external/libusb/libusb/io.c
a120747d561929682cd0276ea4c13fb22fad8554 30-Oct-2010 Peter Stuge <peter@stuge.se> configure.ac: Check for poll.h, and for nfds_t on Darwin

On Linux, assume nfds_t is always available.

On Darwin, fall back to unsigned int when poll() exists but there
is no nfds_t, such as on Mac OS X before 10.4.

On Windows (both MinGW and Cygwin), always use unsigned int instead
of nfds_t, and don't check for poll.h because we use our own poll()
implementation.
/external/libusb/libusb/io.c
478cd4a30728595fd742aa192d8149ee4216d4bc 03-Nov-2010 Peter Stuge <peter@stuge.se> Core: libusb_get_next_timeout() must consider all flying transfers

If transfer->flags indicated that a transfer had a timeout, but no
timeout was actually set, then libusb_get_next_timeout() would look
no further for a timeout, ignoring any transfers later in the list
which had a timeout set.

Since libusb has an internal 60 second timeout this bug could not
cause complete lockup, but it could cause a 60 second timeout even
when a transfer was submitted with a shorter timeout.
/external/libusb/libusb/io.c
67d9ef7b6877e17f2deec81cd41dc0948f6bed4b 06-Oct-2010 Nathan Hjelm <hjelmn@me.com> Remove USBI_OS_HANDLES_TIMEOUT and fix int/isoc timeouts on Darwin

Backends set USBI_TRANSFER_OS_HANDLES_TIMEOUT for transfers instead.
Darwin only handles timeouts for bulk and control transfers, so the
backend now sets that flag accordingly, making libusb core handle
timeouts for interrupt and isochronous transfers. Fixes #31.

Signed-off-by: Nathan Hjelm <hjelmn@me.com>

[stuge: rework libusb_get_next_timeout() and enum usbi_transfer_flags]
[stuge: fix typo; set USBI_TRANSFER_TIMED_OUT flag correctly]
/external/libusb/libusb/io.c
7da756e09fd97efad2b35b5cee0e2b2550aac2cb 24-Jun-2010 Ludovic Rousseau <rousseau@debian.org> Add missing argument to libusb_wait_for_event() documentation, fix #55

In the libusb_wait_for_event() sample code in the section "Letting other
threads do the work for you" the call to libusb_wait_for_event() was not
updated by commit 1df713d622ab4f0b03aad72d903ac7beb8fb3b90, which added
the libusb_context *ctx parameter to the function, so the sample code
was broken until now.
/external/libusb/libusb/io.c
c8bab4e19413d70c515a2eaf747a75b7f66fdc0b 19-Sep-2010 Pete Batard <pbatard@gmail.com> Windows: Make libusb_pollfd() return error

Windows does not have numerical file descriptors but does have the
concept of event sources. Exposing these event sources will require
some careful thought and design, to be completed later.
/external/libusb/libusb/io.c
29f9f9e3af3340df6a955881a93caf9d2a6d08d6 13-Aug-2010 Pete Batard <pbatard@gmail.com> Introduced calling convention (for Windows)

Under Windows, a variety of compilers and configurations are available,
meaning that the manner of parameter passing (e.g. registers vs stack)
can vary.

Match the Windows API calling convention and document this appropriately.
This calling convention will be used regardless of the configuration of
the user's development platform.

The only user-level complication is that all functions used as libusb
callbacks must use the same calling convention as libusb. The
LIBUSB_CALL macro is provided to make this easy.

Signed-off-by: Michael Plante <michael.plante@gmail.com>
Signed-off-by: Pete Batard <pbatard@gmail.com>
[dsd: slight change of strategy, add documentation]
/external/libusb/libusb/io.c
9a4249f8a104b98a15a7e3ba7ecae9a385ed9027 11-Jul-2010 Pete Batard <pbatard@gmail.com> Add Windows support

Via Cygwin/MinGW, libusb now has windows support.
Thanks to contributors: Michael Plante, Orin Eman, Peter Stuge,
Stephan Meyer, Xiaofan Chen.
/external/libusb/libusb/io.c
7211aba6e290f9805e911959b2a43a4b3ec56d4f 25-Jun-2010 Daniel Drake <dan@reactivated.net> Only include sys/time.h on appropriate platforms

This header doesn't exist on windows.
For libusb, determine at configure-time if the header is available.
For libusb.h, use gcc predefined macros to only include the header
on platforms that need it.
/external/libusb/libusb/io.c
fc0af8e3f76925ad09e0fbc6d233d500753ee375 05-Jun-2010 Pete Batard <pbatard@gmail.com> Abstract low-level event handler operations

The Windows backend uses something other than UNIX file descriptors
for event handling. Abstract out the operations to allow for this.
/external/libusb/libusb/io.c
64383fb5b55a74b706967836e81cef61e57df86a 01-Jun-2010 Pete Batard <pbatard@gmail.com> fixes the possibility of using a broken timercmp on Windows

Microsoft's implementation of timercmp does not work for >= or <=.
/external/libusb/libusb/io.c
aa77b02da65afb0332b9e6853dae9e4dcda00bfa 15-Feb-2010 Pete Batard <pbatard@gmail.com> Add type parameter to the list_for_each_entry() and _safe() macros

typeof() is a GCC extension, not supported by target compilers such
as MSVC.
/external/libusb/libusb/io.c
b92b16f437079208c8dfb1dc2380893846a07ee9 19-May-2010 Daniel Drake <dan@reactivated.net> Fix a usbi_pollfd leak in error path

I accidently missed this when applying Pete Batard's earlier patch.
Pointed out by Michael Plante.
/external/libusb/libusb/io.c
d7031ee8e1c449af23b2674fe18d9fc652c9bd80 18-May-2010 Pete Batard <pbatard@gmail.com> Stricter types and casts
/external/libusb/libusb/io.c
9996ccaed740f8fcec4287a478ccaaa573f9865a 18-May-2010 Pete Batard <pbatard@gmail.com> Fixes to error handling and exit codepaths

Various locks and things were being leaked/left open when handling
errors and during deinitialization.

[dsd: small tweaks]
/external/libusb/libusb/io.c
a636df4ca1b87ed3094a87828c022092a80ba613 13-May-2010 Pete Batard <pbatard@gmail.com> Whitespace cleanup
/external/libusb/libusb/io.c
23b5db8b3e353176dfa0635bfb6f0e2658f6e3de 11-May-2010 Peter Stuge <peter@stuge.se> Add internal abstraction for POSIX Threads

This prepares for a Windows backend without dependency on pthreads-w32.

pthread_* is renamed to usbi_* and PTHREAD_* to USBI_*.

A usbi_mutex_static_t and usbi_mutex_static_lock() and _unlock() are
introduced for statically initialized mutexes, since they may be
implemented using other types when pthreads mutexes aren't used.

Move -pthread from libusb/Makefile.am to host-specific THREAD_CFLAGS in
configure.ac. This will enable optional use of -lpthread for cygwin.

[dsd: minor tweaks, and roll in a change based on patches from Pete
Batard to only build dpfp_threaded example when we're using pthreads]
/external/libusb/libusb/io.c
ceb8cacd6d2a4189de0db2ee46d45217511c69be 20-Apr-2010 Daniel Drake <dan@reactivated.net> Document that fd set contents are an internal implementation detail (#36)
/external/libusb/libusb/io.c
0232fc559cdacb9561f982dd6d28feb4435b3e4e 21-Nov-2009 Daniel Drake <dan@reactivated.net> Increase libusb_handle_events() timeout to 60 seconds

The internal timing seems to be working, this will be a better test of
it before we make this timeout unlimited.
/external/libusb/libusb/io.c
0bd7ef5d8697973a026c36c15d6276177b4ec4ea 21-Nov-2009 Daniel Drake <dan@reactivated.net> Refine timerfd header check (#18)

Require glibc-2.9 for the working timerfd support.
/external/libusb/libusb/io.c
11d591058e3f105b0e90c23bbf58b18de691e690 07-Nov-2009 Daniel Drake <dsd@gentoo.org> Update documentation about early completion caveats
/external/libusb/libusb/io.c
4783008b7e711de9cb31631e60dda995f44068de 28-Oct-2009 Daniel Drake <dsd@gentoo.org> Use timerfd for timeout handling

Use a new file descriptor from the timerfd system calls to handle
timeouts. On supported systems, this means that there is less hassle
figuring out when the poll() timeout should be, since
libusb_get_next_timeout() will always return 0 and the timeout events will
be triggered as regular activity on the file descriptor set.

Add API function libusb_pollfds_handle_timeouts() to detect whether
you're on a platform with the timing headache, and flesh out the
surrounding documentation.
/external/libusb/libusb/io.c
69830057547396f893f0d7b3125a05d016313b10 28-Oct-2009 Daniel Drake <dsd@gentoo.org> Transfer locking

At least on Linux, there were some possible races that could occur if
a transfer is cancelled from one thread while another thread is handling
an event for that transfer, or for if a transfer completes while it is
still being submitted from another thread, etc.

On the global level, transfers could be submitted and cancelled at the
same time.

Fix those issues with transfer-level locks.
/external/libusb/libusb/io.c
0334ee642b47dfe1ca9db64b22e7702ea14b3f09 28-Jun-2009 Daniel Drake <dsd@gentoo.org> Add libusb_get_max_iso_packet_size()

As pointed out by Dennis Muhlestein, libusb_get_max_packet_size()
doesn't really do what the documentation might suggest because it
does not consider the number of transaction opportunities per
microframe.

Add a new function to do what is useful for isochronous I/O.
/external/libusb/libusb/io.c
86f79fbf61c2018bdf009c7ebf92b38f3a16fd0c 19-Jun-2009 Nathan Hjelm <hjelmn@mac.com> Darwin: Don't cancel transfers on timeout

...because the OS does this for us.
/external/libusb/libusb/io.c
9196f58bdc8b9e967261df39865215faa5d39cfa 17-Feb-2009 Nathan Hjelm <hjelmn@mac.com> Abstract clock reading into OS layer

This will differ on Linux and Darwin, at least.

[dsd: minor style tweaks]
/external/libusb/libusb/io.c
c754ae294cfe96ec4738d6641137c9e6c56330c7 17-Jan-2009 Daniel Drake <dsd@gentoo.org> Decrement poll() result when internal pipe has been handled

When we receive data on the internal control pipe, we need to correctly
decrement the number of ready file descriptors before passing on the
remaining work to the OS implementation.
/external/libusb/libusb/io.c
b9ca960f2ba271d2b1a58e22b7c70464d69f6c8a 12-Jan-2009 David Moore <dcm@acm.org> Prevent transfer from being submitted twice or improperly canceled

This ensures that tpriv->urbs and tpriv->iso_urbs are always set to NULL
whenever a transfer is not submitted. In this way, submit_*_transfer()
and cancel_*_transfer() can error check to ensure that the transfer is
in the correct state to be either submitted or canceled, preventing
potential memory leaks or double frees.

Signed-off-by: David Moore <dcm@acm.org>
/external/libusb/libusb/io.c
9b4b53453db56ba9c1d707a645bbe6c7a02a3c81 21-Nov-2008 Daniel Drake <dsd@gentoo.org> Improvements to multi-threaded I/O system

Documentation brushed up, and I realised that another function is
needed for tight event handling loops -- they must be able to check
if an open/close operation is trying to interrupt it.
/external/libusb/libusb/io.c
c32aa662769b676ff3247778664fccc71fc427ec 20-Nov-2008 Daniel Drake <dsd@gentoo.org> Pause event handling while opening and closing devices

Ludovic Rousseau found that crashes often occur if you close a device
while another thread is doing event handling.

Fix this by adding an internal control pipe, which the close routines
use to interrupt the event handler and obtain the event handling lock,
ensuring that no other thread is handling events while the device is
closed. After the close completes, it signals all the event handlers
to start up again using the usual mechanism.

Also modified libusb_open() to do a similar thing, so that event
handlers are interrupted in order to realise that a new poll fd has
appeared.
/external/libusb/libusb/io.c
94936cbcfe3f02eb65c8b91e29896604316259d8 28-Aug-2008 Daniel Drake <dsd@gentoo.org> Async I/O documentation touchups
/external/libusb/libusb/io.c
2f8f1b1a900f5b9828e5e2ff93c2b26a44fd9de2 28-Aug-2008 Daniel Drake <dsd@gentoo.org> Doc: fix typo in events lock section
/external/libusb/libusb/io.c
fec6eaa4eecdf7e0b8299157a5dabef94417f193 23-Aug-2008 Daniel Drake <dsd@gentoo.org> Reset internal transfer flags on submit

This fixes a problem pointed out by Lou, where resubmitting a transfer
that previously timed out never timed out again, as if the timeout had
been set to 0.
/external/libusb/libusb/io.c
83a029062c1d2bfb584d7a6ee94915583d37464c 29-Jun-2008 Daniel Drake <dsd@gentoo.org> Add missing GET_CONTEXT()
/external/libusb/libusb/io.c
819e65f880ca43526036e56c65c415042c91f58f 27-Jun-2008 Daniel Drake <dsd@gentoo.org> Allow user data pointer to be passed through pollfd notification API
/external/libusb/libusb/io.c
1df713d622ab4f0b03aad72d903ac7beb8fb3b90 25-Jun-2008 Daniel Drake <dsd@gentoo.org> Introduce contexts to the API

Suggested by David Zeuthen. This allows multiple libraries in the same
process to independently use libusb without interfering.
/external/libusb/libusb/io.c
9818151c60a85aea6af24cb0996a92c3726c9864 25-Jun-2008 Daniel Drake <dsd@gentoo.org> Revert "Temporary workaround for event handling serialization issue"

This reverts commit 2d3a1111caff40ebb87983c861ff548cdc9e5946.
This was based on the assumption that dying threads would automatically
release mutexes, which is not the case.
/external/libusb/libusb/io.c
d5f82893fab3f1c13b1af4ba17aac72479bad7d5 21-Jun-2008 Daniel Drake <dsd@gentoo.org> Overflow handling
/external/libusb/libusb/io.c
217534e4b396081e038ee5f94c813d1668963673 15-Jun-2008 Daniel Drake <dsd@gentoo.org> round up poll timeout

Pointed out by Richard Röjfors, otherwise we end up busy-looping with
a poll() timeout of 0.
/external/libusb/libusb/io.c
2d3a1111caff40ebb87983c861ff548cdc9e5946 29-May-2008 Daniel Drake <dsd@gentoo.org> Temporary workaround for event handling serialization issue

Ludovic Rousseau pointed out that libusb_unlock_events() is not called
when a thread gets terminated with a signal, meaning that event waiters
will not be woken up in this case.

Add a temporary hack to libusb_event_handler_active() so that at least
the other threads will realise on the next iteration of their event
handling loop.

The real fix will likely involve reworking most of this.
/external/libusb/libusb/io.c
4cd249388e4ed2ca03f1263984ab67df5030bb65 25-May-2008 Daniel Drake <dsd@gentoo.org> Take lock before raising event waiters condition

This avoids a race between the user checking for active event handler
and then blocking on the condition variable
/external/libusb/libusb/io.c
7c525480ab3c4db9205bfe30bb0d2bef9096c444 23-May-2008 Daniel Drake <dsd@gentoo.org> Implement serialization of event handlers

Now offers a mechanism to wait for events while another thread is
doing the event handling. Complicates things for MT async apps, but
then again it's a bit of a tricky combination to start with.
/external/libusb/libusb/io.c
e44396a458ecea9e5edd9a7577e617571c76860d 19-May-2008 David Engraf <david.engraf@netcom.eu> critical memory leak in handle_events

This patch closes a critical memory leak in handle_events. The fds
variable is malloced but never freed. When I'm calling
handle_events with a timeout of 0, my system runs out of memory after a
few seconds.
/external/libusb/libusb/io.c
1298c51f516a7bf04ca9add1b7db14417cdc66f3 12-May-2008 Daniel Drake <dsd@gentoo.org> Backend documentation for porting efforts

Hopefully comprehensive enough for people to get started.
/external/libusb/libusb/io.c
fec7c84163e25b8f811632828334d75da82bcb16 11-May-2008 Daniel Drake <dsd@gentoo.org> Handle hot-unplugging

This involved moving from select() to poll() because there is no way to
distinguish usbfs's POLLERR condition with select().
/external/libusb/libusb/io.c
ba5d9a45c06311204f51faef41d1ee215bb5b823 11-May-2008 Daniel Drake <dsd@gentoo.org> Endianness of control setup packets

Document behaviour where host-endian and bus-endian (little) should be
used respectively.

Also remove packed attribute from libusb_control_setup as all fields
are naturally aligned.
/external/libusb/libusb/io.c
885c2a5de69d6b7d8902bb55d6d83680a5a1a6e5 05-May-2008 Daniel Drake <dsd@gentoo.org> documentation touchups
/external/libusb/libusb/io.c
59c205d542b43d79fe28622dbe8f03a3a3300b6f 05-May-2008 Daniel Drake <dsd@gentoo.org> more error code sanitization
/external/libusb/libusb/io.c
88055d4b5913102a90ff666f75fd922c74860dc5 05-May-2008 Daniel Drake <dsd@gentoo.org> Isochronous transfer helper functions
/external/libusb/libusb/io.c
a304eca71f22c6df7d70a901483b30f1b8e93378 05-May-2008 Daniel Drake <dsd@gentoo.org> Detect endpoint halts and unsupported control requests
/external/libusb/libusb/io.c
2012898ffc492317cb428d97077bf5ee0e98e1da 29-Apr-2008 Daniel Drake <dsd@gentoo.org> standardised error codes
/external/libusb/libusb/io.c
d3ab4e3bd4068cba41c1e12c4b175018dc3cb343 28-Apr-2008 Daniel Drake <dsd@gentoo.org> Rename endpoint_type to transfer_type

Matches the USB specs more closely
/external/libusb/libusb/io.c
2ddf81420557d016bbcbf28dda0d8d1c64d16264 28-Apr-2008 Daniel Drake <dsd@gentoo.org> Fix unlocked flying_transfers list access
/external/libusb/libusb/io.c
7ac0a405b4c57db42e88cbcba5f135697f03b646 28-Apr-2008 Daniel Drake <dsd@gentoo.org> Remove libusb_cancel_transfer_sync

This wasn't a particularly nice API. Cancellation should be handled by
the completion handler.
/external/libusb/libusb/io.c
a5006fd7b9dae6f1db7969c8744086ba3a7c027b 27-Apr-2008 Daniel Drake <dsd@gentoo.org> remove extra timeout check

If select() didn't timeout then don't check for more timeouts
/external/libusb/libusb/io.c
3bdafaa359d9c65e1af360b5338e1f25528a8066 27-Apr-2008 Daniel Drake <dsd@gentoo.org> Documentation touchups

Detail that interrupt polling interval is fixed to endpoint bInterval,
and that data may be transferred even on a timeout condition.
/external/libusb/libusb/io.c
0efd2efa65d5513e5754d717d522b2c5c45332e2 19-Apr-2008 Daniel Drake <dsd@gentoo.org> mutex protection for device and handle lists
/external/libusb/libusb/io.c
d2ff2b14a15e5099ff0214502944de30f141a39c 18-Apr-2008 Daniel Drake <dsd@gentoo.org> lock flying_transfers during transfer removal
/external/libusb/libusb/io.c
2569980762cb66804da31e54bef243702da8dfe9 18-Apr-2008 Daniel Drake <dsd@gentoo.org> pollfds mutex protection
/external/libusb/libusb/io.c
f5a33e08ec0da51ccb5e95a5adec50c5211a9bf5 17-Apr-2008 Daniel Drake <dsd@gentoo.org> flying_transfers mutex protection

This marks the beginnings of thread safety
/external/libusb/libusb/io.c
ad6e2b712c5b54af44424e58a2776686314e26b7 11-Apr-2008 Daniel Drake <dsd@gentoo.org> Linux: fire multiple URBs at once for split transfers

This results in a significant performance increase for bulk transfers
larger than 16kb, and fixes a bug where data would be spliced and mixed
between two simultaneously submitted transfers to the same endpoint.

It also allows isochronous transfers larger than 16kb to be submitted.

This commit also improves cancellation - the library now understands
what is going on.
/external/libusb/libusb/io.c
d9b2ce2894ed43d34de6850f2dac50ccabf1db55 02-Apr-2008 Daniel Drake <dsd@gentoo.org> Constify some return data

Make it clear that apps should not mess with these structures
/external/libusb/libusb/io.c
8d809854e2b19c2b7c27ab05e5d76b34e2a5cead 30-Mar-2008 Daniel Drake <dsd@gentoo.org> Rename libusb_poll() to libusb_handle_events()
/external/libusb/libusb/io.c
211f80c9f2a4a58cd2bbf5b7751f45089c8961e7 25-Mar-2008 Daniel Drake <dsd@gentoo.org> Isochronous endpoint I/O

Due to variable-sized structures, this involved changing allocation
mechanism. All transfers must now be allocated and freed through
libusb.

A synchronous function is missing, and I could do with writing a few
more helper functions to simplify things.
/external/libusb/libusb/io.c
0499e9f418607b5786ac0c3e97bc46737a609ca3 20-Mar-2008 Daniel Drake <dsd@gentoo.org> it's called bmRequestType
/external/libusb/libusb/io.c
88884ae4bbe721dac117d5190303cb67852fa5d3 20-Mar-2008 Daniel Drake <dsd@gentoo.org> Save transfer flags before invoking callback

The callback may free the transfer, in which case we can't read the flags
after it has returned.
/external/libusb/libusb/io.c
ead09cde6895df0034a685516987ce253575e9a7 15-Mar-2008 Daniel Drake <dsd@gentoo.org> API documentation

Hopefully mostly complete. Some constants were renamed and move into
enums.
/external/libusb/libusb/io.c
c0c9432d38b22784070dce3a7874c62c31786a27 13-Mar-2008 Daniel Drake <dsd@gentoo.org> Beginnings of cross-platform abstraction

This also includes a libusb_get_pollfds API change
/external/libusb/libusb/io.c
de4c5341d168697baa4c0901c406deb47e78aae7 10-Mar-2008 Daniel Drake <dsd@gentoo.org> Add transfer flags
/external/libusb/libusb/io.c
283ae96c3ccbcee1c3950fce18ae47093ae8200e 09-Mar-2008 Daniel Drake <dsd@gentoo.org> Simplify cancellation API

No need to provide the device here.
/external/libusb/libusb/io.c
ebad1c79688ba603ad017ed0fe2f3c0dc8edd1ad 09-Mar-2008 Daniel Drake <dsd@gentoo.org> Rename libusb_dev_handle to libusb_device_handle
/external/libusb/libusb/io.c
1ac0a7d88f282b6f293c456fac8edb143cbaca3d 09-Mar-2008 Daniel Drake <dsd@gentoo.org> Move synchronous I/O implementation to its own file
/external/libusb/libusb/io.c
66348c90ea4570bf999ac301089e006d0cce1926 09-Mar-2008 Daniel Drake <dsd@gentoo.org> Separate transfer allocation and submission

Leads to some hefty API changes. Now we're much more similar to the
Linux kernel model.

Problems with dealing with asynchronous control transfers are passed
on to the user, basically you must allocate a buffer, start with the
setup, and put the data after. This won't make much sense until
documented (soon...)
/external/libusb/libusb/io.c
d21ebe47ce578c93cd8969be1c933d503e32e5d4 08-Mar-2008 Daniel Drake <dsd@gentoo.org> Rework URB API naming

Now refer to everything as "transfers" as consistent with the USB spec
libusb_transfer is now a kind of transfer handle. To reduce confusion
with libusb_bulk_transfer and libusb_control_transfer, those have been
renamed to libusb_{control,bulk}_transfer_request.
/external/libusb/libusb/io.c
77cea822788e024c848c7f554915f771a2dc1e0f 06-Mar-2008 Daniel Drake <dsd@gentoo.org> Remove ctrl debug code

This was unintentionally committed
/external/libusb/libusb/io.c
b873521a6f575628d535f89278bb67888004d0ca 26-Feb-2008 Daniel Drake <dsd@gentoo.org> Notifications for changes to the fd set

Applications can now be notified when they should start and stop polling
new file descriptors.
/external/libusb/libusb/io.c
637a8d7ff8a11a23588925d9d3003a609bda8075 30-Jan-2008 Daniel Drake <dsd@gentoo.org> Remove timers and signalfd

Instead of timers, add a mechanism for informing the parent app when the
next timeout is due to happen, so that it can call us at that time.

As we no longer use signals, signalfd has also been removed.
/external/libusb/libusb/io.c
8c56abe2e13ed4dd8c15737c21be7b6b1e5cf2ac 26-Jan-2008 Daniel Drake <dsd@gentoo.org> Poll usbfs descriptors directly

We don't need to use signalfd for this functionality because we can poll
the file descriptors for write events.
/external/libusb/libusb/io.c
e3a09ca0b9cb6f46d54a0130f678c6097240a2bd 05-Jan-2008 Daniel Drake <dsd@gentoo.org> Remove more fpusb remnants
/external/libusb/libusb/io.c
132d84bf8ae34bd0892b3d8207a53d87cc0a9cba 04-Jan-2008 Daniel Drake <dsd@gentoo.org> Use "transfer" instead of "msg"

Based on a discussion with Tim Roberts.
/external/libusb/libusb/io.c
dbb3fd871e3972b4e670f3161e7cd2f58f357600 04-Jan-2008 Daniel Drake <dsd@gentoo.org> API renaming: remove fpi and usb_ stuff

fpi changed to usbi.

We should not expose structures with prefix "usb_" in the public
namespace as it is quite likely there will be some conflict somewhere.
Instead, using "libusb_" should be safer.
/external/libusb/libusb/io.c
e9364d72151ae1de9cce4175f330fe1529f02511 04-Jan-2008 Daniel Drake <dsd@gentoo.org> Rename to libusb-1.0

I've taken over the libusb project, and what was previously known as fpusb
will eventually be released as libusb-1.0.
/external/libusb/libusb/io.c