1005 Commits

Author SHA1 Message Date
Chris Dickens b5991a9e02 libusb 1.0.20
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
v1.0.20
2015-09-13 17:37:12 -07:00
Chris Dickens 440fdbbf1a libusb 1.0.20-rc3
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
v1.0.20-rc3
2015-09-05 10:33:07 -07:00
Chris Dickens 7a00443200 core: Add RC string to libusb version message
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-09-05 10:31:45 -07:00
Chris Dickens 127250e0ca Windows: Fix some build warnings/link issues
* Fix MSVC error C4334 (32-bit bit shift)
* Load User32.dll functions at runtime instead of linking directly
  against library (fixes unresovled symbol errors on DDK build)

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-09-05 10:23:38 -07:00
Chris Dickens bf1635b3cb 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>
2015-09-03 17:23:22 -07:00
Chris Dickens 8f2d5bbd88 libusb 1.0.20-rc2
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
v1.0.20-rc2
2015-09-02 19:54:44 -07:00
Chris Dickens 2e1781e7c5 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>
2015-09-02 19:47:15 -07:00
Chris Dickens 8c24a1b930 Examples: fxload improvements
* Add two-stage load support
* Fix leaks in error-handling paths
* Closes #12

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-08-04 23:51:12 -07:00
Chris Dickens efd02e7348 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>
2015-08-04 22:53:03 -07:00
Chris Dickens 13a90e43ac linux_usbfs: Set reap action to CANCELLED only when successful
Prior to this commit, a call to libusb_cancel_transfer() would set
the reap action of the transfer to CANCELLED regardless of whether
the cancellation was successful or not. This can cause the transfer
status to incorrectly report LIBUSB_TRANSFER_CANCELLED when in some
cases this is not the case. This commit adds a check for a successful
cancellation before setting the reap action as such.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-08-04 22:52:14 -07:00
Hans de Goede a6a7b53b63 linux: Assume usbfs path = /dev/bus/usb when using UDEV
On some exotic hardware, e.g. HP ProLiant Moonshot Cartridge servers there
are no usb controllers, so no usb devices at all.

In this case currently libusb_init will fail, because find_usbfs_path
fails. Many apps don't handle this gracefully, and even if they do not crash
the result still is not pretty, e.g.:

unable to initialize libusb: -99

Where one simply would expect empty output.

Since on systems using udev the usbfs path should always be /dev/bus/usb
(as that gets created by udev), simply assume /dev/bus/usb when build with
USE_UDEV and the path cannot be found in the traditional way.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2015-08-04 22:50:54 -07:00
Chris Dickens 4fe0f7e7a9 Misc: Remove autom4te.cache directory from Haiku during 'make dist'
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-07-29 10:15:42 -07:00
Chris Dickens d73bc723aa libusb 1.0.20-rc1
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
v1.0.20-rc1
2015-07-29 01:06:37 -07:00
Chris Dickens a4d2cb89b0 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>
2015-07-29 00:55:32 -07:00
Marcus Meissner f9480d0502 linux_usbfs: use calloc for multiplication
calloc can do n, elemsize multiplication itself

* Closes #74

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-07-28 23:39:23 -07:00
Tim Hutt d473d0b2e6 Use locally defined MIN macro instead of min which is (possibly) defined in windows.h
Some users have to define NOMINMAX which means that windows.h doesn't define min() or max(). Instead of relying on it it is better to use a locally defined function / macro. Fortunately libusbi.h already defines MIN and MAX so we can just use those.

* Closes #72
* Closes #73

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-07-28 23:31:42 -07:00
Chris Dickens 649a500750 Windows: Close HID handles when closing composite devices
* Closes #81

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-07-28 23:10:24 -07:00
Chris Dickens b31e7f8712 Windows: Remove redundant check in windows_claim_interface()
* Checking of this parameter is already done by the core
* Closes #77

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-07-28 23:10:23 -07:00
Chris Dickens 3682baabe0 Windows: Destroy autoclaim_lock during cleanup
* Fixes a resource leak during init error handling or final exit
* Closes #76

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-07-28 23:08:58 -07:00
Gaurav c141457deb linux_usbfs: Fix memory allocation failure.
strdup returns NULL in case memory allocation failure occurs.
If Null check is not there, it will crash while dereferencing in "strrchr".

Closes #66

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-05-19 10:29:50 -07:00
Tobias Klauser 260ff885cd Misc: Fix doxygen comment for MaxPower field with respect to super-speed
The MaxPower field of a configuration descriptor is in units of 8 mA
when the device is operating in super-speed mode according to the USB
3.0 specification, section 9.6.3, table 9-12:

  Maximum power consumption of the device from the
  bus in this specific configuration when the device is
  fully operational. Expressed in 2-mA units when the
  device is operating in high-speed mode and in 8-mA
  units when operating at Gen X speed.
  (i.e., 50 = 100 mA when operating at high-speed and
  50 = 400 mA when operating at Gen X speed).

Adjust the doxygen comment for the MaxPower member of struct
libusb_config_descriptor accordingly.

Closes #69

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-05-13 20:34:12 -07:00
Gaurav c8662f893e Windows: Check for "calloc" allocation failure.
It need to check return value  of calloc. It may fail & return Null.

Closes #67

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-05-13 20:26:57 -07:00
Chris Dickens 9b2c8abf13 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>
2015-05-07 12:45:33 -07:00
Chris Dickens 02f7f859ee 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>
2015-05-07 12:34:35 -07:00
Chris Dickens a1c9895543 examples: Address issues reported by Markus Elfring
* Use sig_atomic_t as data type for variable do_exit
  * Use async-safe function within signal handler

Closes #34

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-04-28 14:56:00 -07:00
Tobias Klauser 0a5b00660b 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>
2015-04-28 13:46:37 -07:00
Matthias Bolte df08e7e290 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>
2015-04-28 12:36:12 -07:00
Chris Dickens 4ec225e835 WinCE: Unlock mutex when error occurs during event handling
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-04-27 17:23:39 -07:00
Chris Dickens a611862c6c WinCE: Fix return from void function
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-04-27 17:23:08 -07:00
Chris Dickens f2ebec710a WinCE: Make whitespace consistent across entire file
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-04-27 17:20:58 -07:00
Chris Dickens 24a6529e05 WinCE: Remove use of dedicated timer thread
Without the ability to set thread affinity, there is no need
to maintain a separate thread to service monotonic clock_gettime()
requests. The determinism of QueryPerformanceCounter() will not
change or improve when run from a dedicated thread, so this just
creates additional overhead.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-04-27 17:19:20 -07:00
Chris Dickens 3071d46df5 WinCE: Remove unused errno header and local variable
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-04-27 16:54:17 -07:00
Antonio Ospite 138d240858 core: generalize comment about setting configurations with claimed interfaces
The comment about libusb_set_configuration() failing when other programs
or drivers have claimed interfaces is valid whether or not the desired
configuration is _different_ from the current one, so generalize the
statement.

While at it also make it more explicit that in case of kernel drivers,
those must be detached from _all_ interfaces before a configuration can
be set.

Finally, move the item as last as the new details also suggest
a solution for when a lightweight reset is desired but kernel drivers
have claimed other interfaces, like in the fingerprint reader example
mentioned in the same section.

Signed-off-by: Antonio Ospite <ao2@ao2.it>
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-04-27 01:47:01 -07:00
Antonio Ospite 76b3d340d0 core: use the actual signature of libusb_get_configuration() in the docs
Use the actual signature of the libusb_get_configuration() function in
the code example in the "caveats" section of the documentation.

Signed-off-by: Antonio Ospite <ao2@ao2.it>
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-04-27 01:46:41 -07:00
Chris Dickens dfb5c0723f Windows: Remove erroneous call to CloseHandle and add comments
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-04-27 01:44:34 -07:00
Chris Dickens 0dca8fdab1 Windows: Improve monotonic clock_gettime() implementation
* Fix setting of timer thread affinity
  * Simplify request mechanism by using a message queue, which also
    yields a 10% performance improvement

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-04-22 00:24:51 -07:00
Chris Dickens 0e10f8f867 Windows: Fix wIndex in setup packet for config descriptor request
Per the USB spec, the wIndex field should be zero or the language ID.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-04-21 22:04:31 -07:00
Pete Batard 56aa106824 windows: fix broken bus number lookup
* The current ancestry lookup for bus number stopped at the first
  non-enumerated grandparent device instead of continuing up to
  the HCD.
* Issue reported by Daniel Pfeffer
2015-03-05 22:18:13 +00:00
Venkatesh Shukla c7401ca1e0 Remove -c flag. Erroneous output caused on android
While cross-building for android, the -c flag was causing errors.
This -c option ends up in Libs.private of libusb-1.0.pc file.
On its usage, it is interpreted as "Compile and assemble, but do not link"
option of gcc. Usage of -c in this way might be unintended.
Hence, removing this option.

Signed-off-by: Venkatesh Shukla <venkatesh.shukla.eee11@iitbhu.ac.in>
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-03-01 01:15:58 -08:00
Chris Dickens dd4da212ee Misc: Update README to include Haiku backend
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-03-01 01:03:04 -08:00
Chris Dickens 998e83a1cd Misc: Remove comment that no longer makes sense
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-03-01 00:51:07 -08:00
Chris Dickens 1c8d030701 linux: Fix format specifiers for sscanf() calls
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-03-01 00:49:01 -08:00
Chris Dickens a886bb02c8 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>
2015-03-01 00:08:23 -08:00
orbitcowboy b000fe1821 misc: fix typos in comments
* Closes #53
2015-02-16 23:15:25 +00:00
parafin d26cc697cc darwin: fix resource leak (cached devices are never freed)
For each new device (processed by hotplug code) darwin_ref_cached_device
is called twice - in process_new_device and in darwin_get_cached_device
(which is called from the first function). But when the device is detached
only one darwin_deref_cached_device is done - in darwin_destroy_device.
So there is inbalance between ref and deref which causes darwin_cached_devices
list to monotonically grow and consume more and more resources over time.
This commit fixes the problem by adding darwin_deref_cached_device call
to darwin_devices_detached.

Closes #52

Signed-off-by: Nathan Hjelm <hjelmn@mac.com>
2015-02-12 11:50:27 -07:00
Chris Dickens d68750a7ac darwin: Fix build break and warning caused by commit 699db154
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-01-31 22:25:24 -08:00
Chris Dickens cbbed3c221 haiku: Transition to use new transfer completion API
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-01-26 18:57:47 -08:00
Chris Dickens 89f0316d38 openbsd: Transition to use new transfer completion API
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-01-26 18:57:44 -08:00
Chris Dickens 4b716a2acb netbsd: Transition to use new transfer completion API
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-01-26 18:57:40 -08:00
Chris Dickens 699db1543f darwin: Transition to use new transfer completion API
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2015-01-26 18:57:29 -08:00