summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Misc: Simplify Haiku build and fix broken parallel buildbaserock/v1.0.20+parallel-build-fixChris Dickens2016-03-0911-839/+767
| | | | | | | | | | | | | | | | | | The Haiku build was previously being done as a nested package due to its C++ requirement, but for some reason setting SUBDIR in an automake conditional breaks parallel builds. To fix this and simplify the Haiku build process, this commit adds an unconditional check for a C++ compiler using AC_PROG_CXX and builds the Haiku sources as part of the main libusb project. Note that AC_PROG_CXX itself does not cause the configure script to fail if a C++ compiler is not found. Therefore on non-Haiku platforms there is no requirement to have a C++ compiler installed in order to build libusb. Closes #121 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* libusb 1.0.20v1.0.20Chris Dickens2015-09-133-3/+3
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* libusb 1.0.20-rc3v1.0.20-rc3Chris Dickens2015-09-053-3/+3
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: Add RC string to libusb version messageChris Dickens2015-09-052-3/+3
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Windows: Fix some build warnings/link issuesChris Dickens2015-09-053-8/+16
| | | | | | | | * 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>
* io: Always complete transfers regardless of timerfd errorsChris Dickens2015-09-032-9/+8
| | | | | | | | | | | | | | | | 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>
* libusb 1.0.20-rc2v1.0.20-rc2Chris Dickens2015-09-023-3/+5
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: Record when a transfer timeout has been handledChris Dickens2015-09-023-4/+8
| | | | | | | | | | | | | 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>
* Examples: fxload improvementsChris Dickens2015-08-042-8/+29
| | | | | | | | * Add two-stage load support * Fix leaks in error-handling paths * Closes #12 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: Correctly report cancellations due to timeoutsChris Dickens2015-08-042-3/+4
| | | | | | | | | | | | 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>
* linux_usbfs: Set reap action to CANCELLED only when successfulChris Dickens2015-08-042-13/+11
| | | | | | | | | | | 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>
* linux: Assume usbfs path = /dev/bus/usb when using UDEVHans de Goede2015-08-042-1/+9
| | | | | | | | | | | | | | | | | | | 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>
* Misc: Remove autom4te.cache directory from Haiku during 'make dist'Chris Dickens2015-07-292-2/+3
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* libusb 1.0.20-rc1v1.0.20-rc1Chris Dickens2015-07-294-6/+31
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* API: Add libusb_free_pollfds() functionChris Dickens2015-07-294-4/+26
| | | | | | | | | 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>
* linux_usbfs: use calloc for multiplicationMarcus Meissner2015-07-282-6/+3
| | | | | | | | calloc can do n, elemsize multiplication itself * Closes #74 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Use locally defined MIN macro instead of min which is (possibly) defined in ↵Tim Hutt2015-07-283-3/+3
| | | | | | | | | | | 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>
* Windows: Close HID handles when closing composite devicesChris Dickens2015-07-282-10/+17
| | | | | | * Closes #81 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Windows: Remove redundant check in windows_claim_interface()Chris Dickens2015-07-282-4/+1
| | | | | | | * Checking of this parameter is already done by the core * Closes #77 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Windows: Destroy autoclaim_lock during cleanupChris Dickens2015-07-282-1/+3
| | | | | | | * Fixes a resource leak during init error handling or final exit * Closes #76 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* linux_usbfs: Fix memory allocation failure.Gaurav2015-05-192-1/+4
| | | | | | | | | 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>
* Misc: Fix doxygen comment for MaxPower field with respect to super-speedTobias Klauser2015-05-132-2/+3
| | | | | | | | | | | | | | | | | | | | | | 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>
* Windows: Check for "calloc" allocation failure.Gaurav2015-05-131-0/+4
| | | | | | | | 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>
* core: Copy transfer timeout to local variable before usingChris Dickens2015-05-072-9/+6
| | | | | | | | | | | | 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>
* core: Miscellaneous transfer timeout improvementsChris Dickens2015-05-072-9/+7
| | | | | | | | | | | | | * 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>
* examples: Address issues reported by Markus ElfringChris Dickens2015-04-282-11/+16
| | | | | | | | | * 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>
* core: Remove unused member add_iso_packet_size from struct usbi_os_backendTobias Klauser2015-04-2810-16/+2
| | | | | | | | | | | | | | | 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>
* Misc: Remove unnecessary \n from log messagesMatthias Bolte2015-04-288-12/+12
| | | | | | | | | | | 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>
* WinCE: Unlock mutex when error occurs during event handlingChris Dickens2015-04-272-1/+3
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* WinCE: Fix return from void functionChris Dickens2015-04-272-2/+2
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* WinCE: Make whitespace consistent across entire fileChris Dickens2015-04-272-63/+64
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* WinCE: Remove use of dedicated timer threadChris Dickens2015-04-272-185/+21
| | | | | | | | | | 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>
* WinCE: Remove unused errno header and local variableChris Dickens2015-04-272-3/+1
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: generalize comment about setting configurations with claimed interfacesAntonio Ospite2015-04-272-4/+5
| | | | | | | | | | | | | | | | | | | 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>
* core: use the actual signature of libusb_get_configuration() in the docsAntonio Ospite2015-04-272-2/+3
| | | | | | | | 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>
* Windows: Remove erroneous call to CloseHandle and add commentsChris Dickens2015-04-272-2/+3
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Windows: Improve monotonic clock_gettime() implementationChris Dickens2015-04-223-137/+125
| | | | | | | | * 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>
* Windows: Fix wIndex in setup packet for config descriptor requestChris Dickens2015-04-212-3/+3
| | | | | | Per the USB spec, the wIndex field should be zero or the language ID. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* windows: fix broken bus number lookupPete Batard2015-03-052-3/+6
| | | | | | | * 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
* Remove -c flag. Erroneous output caused on androidVenkatesh Shukla2015-03-012-4/+1
| | | | | | | | | | | 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>
* Misc: Update README to include Haiku backendChris Dickens2015-03-012-4/+5
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Misc: Remove comment that no longer makes senseChris Dickens2015-03-012-4/+1
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* linux: Fix format specifiers for sscanf() callsChris Dickens2015-03-012-3/+3
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: Add internal transfer state managementChris Dickens2015-03-014-122/+174
| | | | | | | | | | | | | | | | | | 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>
* misc: fix typos in commentsorbitcowboy2015-02-163-4/+4
| | | | * Closes #53
* darwin: fix resource leak (cached devices are never freed)parafin2015-02-122-1/+13
| | | | | | | | | | | | | | | 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>
* darwin: Fix build break and warning caused by commit 699db154Chris Dickens2015-01-312-3/+2
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* haiku: Transition to use new transfer completion APIChris Dickens2015-01-264-52/+25
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* openbsd: Transition to use new transfer completion APIChris Dickens2015-01-262-73/+8
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* netbsd: Transition to use new transfer completion APIChris Dickens2015-01-262-73/+8
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>