Daniel Drake [Sun, 14 Jun 2009 18:23:21 +0000 (19:23 +0100)]
Don't terminate enums with commas
g++ -pedantic doesn't like this
Reported by Eberhard Mattes
Daniel Drake [Sat, 13 Jun 2009 16:19:07 +0000 (17:19 +0100)]
v1.0.2 release
Daniel Drake [Wed, 10 Jun 2009 20:42:05 +0000 (21:42 +0100)]
Linux: fix config descriptor parsing on big-endian systems
Multi-byte fields in the configuration descriptors that come back from
usbfs are always in bus endian format.
Thanks to Joe Jezak for help investigating and fixing this.
Nathan Hjelm [Sun, 7 Jun 2009 21:29:35 +0000 (22:29 +0100)]
Darwin: improve handling of disconnected devices
Nathan Hjelm [Sun, 7 Jun 2009 21:26:37 +0000 (22:26 +0100)]
Darwin: fix parsing of config descriptors
This was a confusion between configuration numbers and zero-based
configuration indexes.
Daniel Drake [Sun, 7 Jun 2009 21:19:53 +0000 (22:19 +0100)]
Eliminate -Wsign-compare compiler warnings
This was due to an API inconsistency which can be safely worked around.
Hopefully we'll remember to fix the API next time we come to break
things.
David Moore [Thu, 28 May 2009 06:15:54 +0000 (23:15 -0700)]
Make synchronous transfer APIs robust against signal interruption
libusb_control_transfer and libusb_bulk_transfer are designed to be
synchronous such that control is not returned until the transfer
definitively succeeds or fails. That assumption is violated if a signal
interrupts these functions because there is no way for the application
to continue waiting for the transfer without resubmitting it. This
patch changes these synchronous APIs so they do not abort in the case of
a signal interruption.
Signed-off-by: David Moore <dcm@acm.org>
Alex Vatchenko [Thu, 28 May 2009 19:58:50 +0000 (15:58 -0400)]
pre-gcc-3.4 compatibility
The -fvisibility and -Wno-pointer-sign options are not available on
old GCC versions.
Daniel Drake [Tue, 26 May 2009 19:53:26 +0000 (15:53 -0400)]
Fix memory leak in config descriptor parsing
Pointed out by Martin Koegler.
Daniel Drake [Tue, 12 May 2009 23:20:51 +0000 (19:20 -0400)]
Update AUTHORS
Daniel Drake [Tue, 12 May 2009 23:03:37 +0000 (19:03 -0400)]
v1.0.1 release
Daniel Drake [Tue, 12 May 2009 23:01:44 +0000 (19:01 -0400)]
Add BUGS file
Probably missed a couple of outstanding issues
Nathan Hjelm [Mon, 23 Mar 2009 01:13:29 +0000 (21:13 -0400)]
Darwin: get_config_descriptor bugfixes
Daniel Drake [Wed, 25 Feb 2009 15:33:33 +0000 (12:33 -0300)]
Fix compilation of Darwin backend
My fault. Reported by ihryamzik@gmail.com
Nathan Hjelm [Tue, 17 Feb 2009 00:39:29 +0000 (21:39 -0300)]
Darwin backend
Nathan Hjelm [Tue, 17 Feb 2009 00:30:49 +0000 (21:30 -0300)]
Make endianness macros endian-independent
Implementation suggested by David Moore. Needed for proper universal
code support on Darwin.
Nathan Hjelm [Tue, 17 Feb 2009 00:25:18 +0000 (21:25 -0300)]
Abstract clock reading into OS layer
This will differ on Linux and Darwin, at least.
[dsd: minor style tweaks]
Daniel Drake [Tue, 17 Feb 2009 00:20:28 +0000 (21:20 -0300)]
Fix endianness in device descriptors
Pointed out by Nathan Hjelm.
Nathan Hjelm [Tue, 17 Feb 2009 00:13:52 +0000 (21:13 -0300)]
Only link with librt on Linux
[dsd: tweak configure.ac change]
Hans Ulrich Niedermann [Sun, 25 Jan 2009 23:31:48 +0000 (00:31 +0100)]
API docs: describe libusb_transfer_cb_fn type
Add some text describing the libusb_transfer_cb_fn function type
with the semantics I have gathered from reading other parts of
the API docs, referring to the proper section for more details.
[dsd: tweaked the description slightly]
Hans Ulrich Niedermann [Sun, 25 Jan 2009 17:21:59 +0000 (18:21 +0100)]
Make empty array in struct compatible with C99
If the compiler is known to be running in C99 mode,
use "flexible array members" ("foo[]").
If the compiler is running in any other mode, continue
using the non-standard but widely common "foo[0]" syntax.
Hans Ulrich Niedermann [Sun, 25 Jan 2009 17:20:45 +0000 (18:20 +0100)]
Avoid signedness errors in API docs example code
Daniel Drake [Sat, 17 Jan 2009 00:25:40 +0000 (00:25 +0000)]
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.
David Moore [Mon, 12 Jan 2009 05:46:17 +0000 (21:46 -0800)]
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>
David Moore [Thu, 8 Jan 2009 06:31:09 +0000 (22:31 -0800)]
Linux: Fix race condition in cancel_bulk_transfer()
This fixes a race condition in cancel_bulk_transfer(). In the old
version, awaiting_reap and awaiting_discard are incremented in
cancel_bulk_transfer() and decremented in handle_bulk_completion().
However, since these events may take place in two different threads,
these variables may reach zero before all URBs have been canceled,
triggered spurious callbacks and duplicate frees.
This changes the logic to use a single variable "num_retired" to replace
both awaiting_reap and awaiting_discard. num_retired is incremented
only in handle_bulk_completion() and thus there is no race. The handler
will know that all URBs have been canceled when num_retired becomes
equal to num_urbs.
This change also simplifies a great deal of the logic in both functions
and is a net reduction in the amount of code.
Note that some variables such as "reap_action" probably need to still be
protected by a mutex, and this patch does not address that issue.
Signed-off-by: David Moore <dcm@acm.org>
Daniel Drake [Sat, 13 Dec 2008 20:06:49 +0000 (20:06 +0000)]
v1.0.0 release
It's here!
Mikhail Gusarov [Wed, 10 Dec 2008 09:24:05 +0000 (15:24 +0600)]
EOL-whitespace fixes
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.ent>
Daniel Drake [Tue, 9 Dec 2008 21:43:37 +0000 (21:43 +0000)]
Linux: fix reading of active configuration
Shannon Chuang pointed out that we only read 1 byte into an
uninitialized integer, and then return the whole thing.
Daniel Drake [Tue, 9 Dec 2008 21:39:11 +0000 (21:39 +0000)]
Fix double free in descriptor parsing error path
Pointed out by Shannon Chuang.
Daniel Drake [Fri, 21 Nov 2008 13:28:32 +0000 (13:28 +0000)]
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.
Daniel Drake [Fri, 21 Nov 2008 11:00:47 +0000 (11:00 +0000)]
SourceForge website upload system changed
Daniel Drake [Fri, 21 Nov 2008 10:54:57 +0000 (10:54 +0000)]
v0.9.4 release
Daniel Drake [Thu, 20 Nov 2008 15:31:10 +0000 (15:31 +0000)]
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.
Bastien Nocera [Thu, 30 Oct 2008 14:35:23 +0000 (14:35 +0000)]
Add libusb_attach_kernel_driver()
Add support for re-attaching a driver to a device under Linux.
[dsd: fixed handling of return value, and added LIBUSB_ERROR_BUSY case]
Daniel Drake [Sun, 2 Nov 2008 21:45:54 +0000 (21:45 +0000)]
Linux: handle low-level transfer errors
Handle more URB error status codes, thanks to Lou and Alan Stern.
Aurelien Jarno [Thu, 4 Sep 2008 11:50:49 +0000 (13:50 +0200)]
Support for out-of-tree building
Contrary to libusb 0.1, libusb 1.0 does not support out-of-tree building
for the documentation part. This patch fixes that by using a
doxygen.cfg.in file, which contains @top_srcdir@ to refer to the
location of the libusb source code.
Daniel Drake [Sun, 2 Nov 2008 15:00:39 +0000 (15:00 +0000)]
Document the logging style
Suggested by Lou.
Daniel Drake [Thu, 28 Aug 2008 03:44:24 +0000 (22:44 -0500)]
Async I/O documentation touchups
Daniel Drake [Thu, 28 Aug 2008 02:23:10 +0000 (21:23 -0500)]
Doc: fix typo in events lock section
Daniel Drake [Sat, 23 Aug 2008 06:00:21 +0000 (01:00 -0500)]
v0.9.3 release
Daniel Drake [Sat, 23 Aug 2008 05:57:44 +0000 (00:57 -0500)]
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.
Daniel Drake [Sun, 10 Aug 2008 22:09:48 +0000 (17:09 -0500)]
Add libusb_get_configuration prototype
Pointed out by Lou
Daniel Drake [Sat, 19 Jul 2008 22:51:28 +0000 (17:51 -0500)]
v0.9.2 release
Daniel Drake [Wed, 16 Jul 2008 14:22:12 +0000 (09:22 -0500)]
Linux: fix sysfs directory handling
The length of the directory name varies, e.g. when you have nested hubs.
Use dynamic allocation to be able to deal with any length of name.
David Engraf [Wed, 16 Jul 2008 14:16:38 +0000 (09:16 -0500)]
Linux: correct usage of MAX_PATH
Thanks to clarification from Artem Egorkine, MAX_PATH already includes
space for the trailing NULL.
Daniel Drake [Wed, 9 Jul 2008 02:15:54 +0000 (21:15 -0500)]
Linux: fix bulk/iso transfer double-cancellation
Reset counters to 0 so that it's possible to cancel a transfer twice
without breaking things. Not sure that I want to support this properly,
but this makes it work at least.
Daniel Drake [Sun, 29 Jun 2008 02:28:44 +0000 (21:28 -0500)]
v0.9.1 release
Daniel Drake [Sun, 29 Jun 2008 02:24:49 +0000 (21:24 -0500)]
Add missing GET_CONTEXT()
Daniel Drake [Sun, 29 Jun 2008 02:18:41 +0000 (21:18 -0500)]
Linux: Compatibility with new sysfs descriptors file
As of 2.6.26, the descriptors file now includes all descriptors, not
just the active one.
Daniel Drake [Fri, 27 Jun 2008 03:47:05 +0000 (22:47 -0500)]
Allow user data pointer to be passed through pollfd notification API
Daniel Drake [Wed, 25 Jun 2008 04:01:51 +0000 (23:01 -0500)]
Introduce contexts to the API
Suggested by David Zeuthen. This allows multiple libraries in the same
process to independently use libusb without interfering.
Daniel Drake [Wed, 25 Jun 2008 02:31:13 +0000 (21:31 -0500)]
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.
Daniel Drake [Sat, 21 Jun 2008 04:04:53 +0000 (23:04 -0500)]
Overflow handling
Artem Egorkine [Tue, 17 Jun 2008 23:27:38 +0000 (18:27 -0500)]
a fix for SIGSEGV in handle_bulk_completion()
We cannot dereference tpriv after calling
usbi_handle_transfer_cancellation() because that function may invoke
the user-supplied callback which may free the transfer.
Daniel Drake [Tue, 17 Jun 2008 03:50:50 +0000 (22:50 -0500)]
Refine configuration selection again
At Alan Stern's suggestion, just offer the bare "set configuration" and
"get configuration" functionality, and let applications worry about the
specific race conditions and unusual situations.
Daniel Drake [Sun, 15 Jun 2008 20:29:38 +0000 (15:29 -0500)]
docs update
Add a THANKS file, make copyright notices easily accessible, update TODO
Daniel Drake [Sun, 15 Jun 2008 20:23:29 +0000 (15:23 -0500)]
round up poll timeout
Pointed out by Richard Röjfors, otherwise we end up busy-looping with
a poll() timeout of 0.
Felipe Balbi [Sun, 8 Jun 2008 09:34:48 +0000 (12:34 +0300)]
fix doc about libusb_open()
libusb_open() returns int instead of libusb_device_handle.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
[dsd: small correction]
Daniel Drake [Thu, 29 May 2008 16:26:26 +0000 (17:26 +0100)]
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.
Daniel Drake [Thu, 29 May 2008 11:35:01 +0000 (12:35 +0100)]
Refine libusb_set_configuration() semantics
Applications will generally want to set a configuration before claiming
interfaces. The problem is that the interface may already be set, and
someone else may have claimed an interface (meaning that all calls to
set_configuration will fail, even if it's for the same configuration).
There are now 2 options:
1. Use the new libusb_get_configuration() to determine active
configuration before calling libusb_set_configuration()
2. Or just call libusb_set_configuration() as usual, which will do
nothing if that configuration is already active.
Daniel Drake [Sun, 25 May 2008 22:42:42 +0000 (23:42 +0100)]
v0.9.0 release
First libusb-1.0 beta release
Daniel Drake [Sun, 25 May 2008 21:59:09 +0000 (22:59 +0100)]
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
Daniel Drake [Fri, 23 May 2008 14:57:07 +0000 (15:57 +0100)]
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.
Daniel Drake [Sat, 24 May 2008 20:28:31 +0000 (21:28 +0100)]
allow LIBUSB_DEBUG env var to control message verbosity at runtime
Based on ideas from Ludovic Rousseau
Daniel Drake [Fri, 23 May 2008 14:58:11 +0000 (15:58 +0100)]
don't print messages by default
Add libusb_set_debug() API to set message verbosity.
Ludovic Rousseau pointed out that applications may close stdout/stderr
descriptors, which might then be reused.
Daniel Drake [Mon, 19 May 2008 14:43:27 +0000 (15:43 +0100)]
Fix memory leak in libusb_control_transfer
Pointed out by David Engraf: we weren't freeing the transfer buffer
David Engraf [Mon, 19 May 2008 14:16:32 +0000 (15:16 +0100)]
Linux: fix handling of ioctl failure
The return value of some ioctl commands in linux_usbfs.c are not
handeled correct. The ioctl function returns != 0 and errno is set with
the error code.
David Engraf [Mon, 19 May 2008 14:13:38 +0000 (15:13 +0100)]
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.
Daniel Drake [Fri, 16 May 2008 22:50:20 +0000 (23:50 +0100)]
More informative libusb_open() return code
Hopefully one of the last API tweaks...
Daniel Drake [Fri, 16 May 2008 21:37:56 +0000 (22:37 +0100)]
Fix endianness with descriptor handling
Alan Stern pointed out that usbfs gives host-endian data, but sysfs gives
bus-endian.
Daniel Drake [Mon, 12 May 2008 17:46:37 +0000 (18:46 +0100)]
Backend documentation for porting efforts
Hopefully comprehensive enough for people to get started.
Daniel Drake [Mon, 12 May 2008 14:43:30 +0000 (15:43 +0100)]
Linux: fix caching of guessed configuration
Reported and tested by Xiaofan Chen
Rob Walker [Sun, 11 May 2008 20:14:18 +0000 (21:14 +0100)]
Linux: fix bulk transfer early completion
We were forgetting about the remaining urbs when a non-final urb
completed early.
[dsd: some touchups and a warning message for a corner case that we don't handle]
Daniel Drake [Sun, 11 May 2008 19:31:58 +0000 (20:31 +0100)]
Handle hot-unplugging
This involved moving from select() to poll() because there is no way to
distinguish usbfs's POLLERR condition with select().
Daniel Drake [Sun, 11 May 2008 15:04:35 +0000 (16:04 +0100)]
Documentation work
Daniel Drake [Sun, 11 May 2008 14:36:24 +0000 (15:36 +0100)]
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.
Daniel Drake [Sun, 11 May 2008 14:11:59 +0000 (15:11 +0100)]
Document that releasing interface causes SET_INTERFACE control request
Daniel Drake [Sat, 10 May 2008 20:45:42 +0000 (21:45 +0100)]
Support unconfigured devices
Daniel Drake [Sat, 10 May 2008 19:56:44 +0000 (20:56 +0100)]
Linux: fix caching of active configuration for non-sysfs
Daniel Drake [Sat, 10 May 2008 13:42:43 +0000 (14:42 +0100)]
Fetch configurations by index (not value)
Otherwise there is no way to know which values to look for.
Daniel Drake [Fri, 9 May 2008 23:12:53 +0000 (00:12 +0100)]
Linux: comprehensive sysfs vs usbfs access
Be more flexible when certain parts of sysfs are not available.
Daniel Drake [Fri, 9 May 2008 18:38:13 +0000 (19:38 +0100)]
Linux: no need to store usbfs node path
This can be computed from bus number and device address
Daniel Drake [Fri, 9 May 2008 13:34:31 +0000 (14:34 +0100)]
Rework configuration handling
libusb no longer caches descriptors in libusb_device but backends are
intended to be able to provide copies from memory. In the common linux
case we can use sysfs.
Daniel Drake [Fri, 9 May 2008 13:36:14 +0000 (14:36 +0100)]
libusb_get_device_list() can return negative error code
Daniel Drake [Thu, 8 May 2008 22:09:21 +0000 (23:09 +0100)]
Linux: fix clear_halt implementation
The ioctl expects an integer.
Bug found with the assistance of Soumen Mondal
Daniel Drake [Thu, 8 May 2008 22:04:52 +0000 (23:04 +0100)]
Documentation work
Partially based on some libusb-devel discussions
Daniel Drake [Mon, 5 May 2008 21:57:48 +0000 (22:57 +0100)]
Linux: enumerate devices and descriptors from sysfs
Suggested by Alan Stern. This avoids waking up any suspended USB devices.
sysfs is not available on all systems, so the usbfs mechanism is still
in place as a fallback.
Daniel Drake [Mon, 5 May 2008 20:34:31 +0000 (21:34 +0100)]
documentation touchups
Daniel Drake [Mon, 5 May 2008 20:17:03 +0000 (21:17 +0100)]
more error code sanitization
Daniel Drake [Mon, 5 May 2008 19:57:43 +0000 (20:57 +0100)]
Isochronous transfer helper functions
Daniel Drake [Mon, 5 May 2008 16:54:33 +0000 (17:54 +0100)]
free open devices on exit
Daniel Drake [Mon, 5 May 2008 16:47:49 +0000 (17:47 +0100)]
move descriptor parsing into main library
OS modules now provide functionality for fetching device/config
descriptors
Daniel Drake [Mon, 5 May 2008 15:22:33 +0000 (16:22 +0100)]
Detect endpoint halts and unsupported control requests
Daniel Drake [Mon, 5 May 2008 00:00:31 +0000 (01:00 +0100)]
Linux: fix logical URB allocation
We were allocating the wrong number of URBs for transfers of size
multiples of 16k.
Daniel Drake [Sun, 4 May 2008 15:51:23 +0000 (16:51 +0100)]
add functionality for querying and detaching kernel driver
Daniel Drake [Sun, 4 May 2008 15:20:46 +0000 (16:20 +0100)]
Descriptor reading functionality
Daniel Drake [Sun, 4 May 2008 13:22:16 +0000 (14:22 +0100)]
sanitized error returns from synchronous I/O functions
Daniel Drake [Sun, 4 May 2008 13:10:19 +0000 (14:10 +0100)]
implement libusb_reset_device()
Daniel Drake [Sun, 4 May 2008 12:46:41 +0000 (13:46 +0100)]
Add functionality to clear endpoint halt conditions
Daniel Drake [Sat, 3 May 2008 23:51:59 +0000 (00:51 +0100)]
Fix libusb_get_device_list return value
It was documented to return the list length, but was returning 0.