Commits
master
Name already in use
Commits on Sep 10, 2020
-
examples/testlibusb: Print speed of devices
Print the speed of devices to exercise libusb_get_device_speed(). Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-
examples/testlibusb: Add support for testing libusb_wrap_sys_device()
Sometimes it is useful to be able to test libusb_wrap_sys_device(), add support for this to the testlibusb example Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-
linux: Fix libusb_get_device_speed() not working on wrapped devices
We don't have a sysfs_dir for wrapped devices, so we cannot read the speed from sysfs. The Linux kernel has supported a new ioctl to get the speed directly from the fd for a while now, use that when we don't have sysfs access. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1871818 Reported-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Commits on Aug 25, 2020
-
events_posix: Remove unnecessary and incorrect assertion
Thomas Chiantia reports that the POSIX events abstraction is failing periodically because of incorrect assertion logic. Remove it as there is another (correct) check further into the function that will serve check the intended condition. Closes #775 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Commits on Aug 24, 2020
-
core: Ensure that reported event bits are initialized
Closes #774 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Commits on Aug 23, 2020
-
Make README the real file and README.md the symbolic link to fix an installation issue with npm packaging tool. Fixes libusb/libusb#772 " README file not included with npm packaging tools #772 " Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
Commits on Aug 18, 2020
-
Fix typos detected by codespell and manual inspection
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
Documentation: Specify the constraint of the 'completed' parameter
Closes #482 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
Documentation: Update the Windows binary snapshot README regarding UsbDk
Closes #443 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
Documentation: Add details regarding thread-safety
Closes #352 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
Documentation: Improve details of libusb_transfer's 'user_data' field
Closes #351 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
Documentation: Add a note regarding the execution context of callbacks
Make it more clear that callbacks are only called when libusb_handle_events() is called and that all callbacks will be called on the same thread calling that function. Closes #349 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
Documentation: Add details regarding timeouts and partial transfer of…
… data Closes #348 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
Documentation: Add section regarding transfer length limitations
Closes #204 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
Windows: Update INSTALL_WIN.txt
Add info regarding where the 'INSTALL' file comes from. Remove link for Windows SDKs as this is no longer relevant. Update to account for Visual Studio 2019. Closes #235 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
Autotools: Use built-in shell tests and exec autoreconf
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
Windows: Fix I/O completion port thread behavior on error
The GetQueuedCompletionStatus() returns FALSE when the I/O operation itself does not complete successfully. The I/O completion thread should therefore not exit on this condition. Adjust the check to verify that an OVERLAPPED structure was provided and use an explicit completion key value in the exit path to disambiguate receiving a valid NULL OVERLAPPED pointer. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Commits on Aug 17, 2020
-
Windows: Improve how root hubs are reported
Microsoft provides very little information about the actual root hub characterstics beyond the number of ports. Determining the maximum supported speed of the root hub is not directly possible but instead requires that a device matching the highest speed of the root hub is connected. Additionally, Windows 8 or later is required for _any_ successful detection of SuperSpeed devices. One other inconvenience is that there are no descriptors exposed for root hubs. This does not fit well with the structure of the library because root hubs are considered first-class devices. This change addresses some of these shortcomings. Each root hub is now given a configuration descriptor that is matched to the fastest speed detected for the root hub. The information is most accurate on Windows 8 or later, but the best information possible is constructed on earlier versions. The device descriptor is also adjusted accordingly based on the detected speed. This solution is not perfect but is better than the status quo. Closes #688 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
Windows: Prevent NULL pointer dereference when ancestor is missing
A buggy virtual USB device driver can cause the device enumeration process to fail during the init_device() function when trying to determine the bus number of the device. Guard against this by checking that the ancestor device was actually found and skipping the bogus device when there is no ancestor. Closes #491 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Commits on Aug 13, 2020
-
descriptor: Miscellaneous improvements to the overall source
Introduce union types that simplify working with descriptors. Previously there were simple arrays declared on the stack and these were either parsed into the target descriptor structure or were accessed with magic offsets into the array. Using the union type allows the descriptors to be read with the need to parse it into a separate structure. Fix a memory leak that would occur in the interface parsing code if the usbi_reallocf() function failed. Each interface has a separately allocated array of endpoints and potential extra descriptors. These cannot be freed when using usbi_reallocf(), so switch to use realloc(). Fix an obscure limitation where extra descriptors would not be appended to the configuration is any previous extra descriptors had already been found. Make the error checking and error messages consistent across all the parsing functions. This includes printing unknown or unexpected descriptor types in hex format, which is often easier to lookup as most specifications use hex notation. Constify the input buffer argument to the parsing functions. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
core: Optimize check for pending events
Prior to this commit, a check for whether any events are pending involved checking four different variables within the context. Optimize this by using multiple bits within a single unsigned integer to represent all the possible events that could be pending. This reduces the check for whether any events are pending to a single load. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
On systems that support it, using an eventfd for simple signalling is much more efficient than using a pipe. Add detection of eventfd to the configure script and wire it up in the POSIX event abstraction. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Commits on Aug 12, 2020
-
core: Introduce platform events abstraction
The way in which system handles or resources are represented differs greatly between Unix-like operating systems and Windows. Ever since Windows support was added to libusb, Windows been emulating principles of Unix-like operating systems such as file descriptors and poll(). This commit introduces an abstraction layer that completely removes the need to perform any emulation. Fundamentally there are three things that each platform provides to libusb: 1) A signallable event 2) A timer (not required, but useful) 3) A means to wait for event sources such as the above to be triggered The POSIX abstraction for Unix-like operating systems uses file descriptors as the "handles" to the underlying system resources. The signallable event is implemented using a pipe, the timer as a timerfd (where supported) and the poll() system call is used to wait for events. The Windows abstraction uses native HANDLEs as the "handles" to the underlying system resources. The signallable event is implemented using a manual-reset event, the timer as a manual-reset waitable timer, and the WaitForMultipleObjects() system call is used to wait for events. Closes #252 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Commits on Aug 11, 2020
-
Windows: Use I/O completion ports for transfers
As a first step in removing the Windows poll() emulation, switch the transfers to use an I/O completion port. A dedicated per-context thread will wait on the I/O completion port and report transfer completions using usbi_signal_transfer_completion(). This enables the complete removal of the handle_events() function for the Windows backend and removes the notion of one "file descriptor" per transfer. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
core: Introduce list iteration helpers
The syntax for traversing over lists is somewhat cluttered. It could be made much better with the use of the 'typeof' keyword, but unfortunately this is not universally supported by all compilers. We can, however, improve the situation by introducing some macros for the common cases. To that end, this commit introduces a number of 'for_each' macros that iterate over a specific linked list. Current syntax: list_for_each_entry(itransfer, &ctx->flying_transfers, list, struct usbi_transfer) New syntax: for_each_transfer(ctx, itransfer) Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Commits on Aug 10, 2020
-
OpenBSD: support libusb_get_port_number
From mpi@openbsd.org Fixes #314 Closes #764 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
OpenBSD: allow opening ugen devices multiple times
Fix an OpenBSD backend bug where an existing open file descriptor is overwritten if a libusb user attempts to open the same ugen(4) device multiple times. This was observed with sane-backends and broke scanning. Fix from stsp@openbsd.org Closes #763 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
API docs: Elaborate on "NOT_SUPPORTED" status for set_configuration()
Closes #762 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
libusb: fix a memory leak in sunos_new_string_list func
In sunos_new_string_list func, if alloc list->string fails, we will return NULL without free list, which has alread been allocated successfully. Fixes: 1734873 ('Solaris backend depends on Solaris private symbols') Closes #756 Signed-off-by: Zhiqiang Liu <lzhq28@mail.ustc.edu.cn> Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
stress: test_get_device_list: change printf format for ssize_t
The type of list_size is ssize_t. First idea was to use "%zd" printf format specifier. But that is not supported by Visual Studio 2013. Use "%ld" + cast list_size to long. Closes #751 Suggested-by: Chris Dickens <christopher.a.dickens@gmail.com> Signed-off-by: Uri Lublin <uril@redhat.com> Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-
descriptor: Fix alignment for 32-bit words in parse_descriptor
parse_descriptor was aligning 32-bit words to 2 bytes, instead of 4 bytes. This didn't cause any issues before, because the only time the 32-bit word code path is used is from a 3 byte offset (which incidentally aligns to 4 bytes). However, a 1 byte offset would incorrectly align to 2 bytes. Closes #734 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Commits on Jul 16, 2020
-
winusb: setting a non-default config not supported
Just because winusb doesn't seem to support setting a different configuration, that doesn't mean it's an invalid parameter. It's generally supported by libusb, just not on this platform. So return LIBUSB_ERROR_NOT_SUPPORTED instead of LIBUSB_ERROR_INVALID_PARAM. Closes #743 Closes #752 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Commits on Jun 17, 2020
-
darwin: Fix invalid GetPipePropertiesV3 argument
GetPipePropertiesV3 seems to require that the bVersion field of the properties argument be set before calling it: "Version of the structure. Currently kUSBEndpointPropertiesVersion3. Need to set this when using this structure" Not doing so results in an invalid argument error. Closes #744 Signed-off-by: Ido Yariv <ido@wizery.com> Signed-off-by: Nathan Hjelm <hjelmn@google.com>
Commits on Jun 12, 2020
-
os/darwin: use IOUSBDevice as darwin_device_class explicitly
kIOUSBDeviceClassName define from IOUSBLib.h file was changed from IOUSBDevice to IOUSBHostDevice in macOS Catalina. In previous macOS versions, it was always defined as IOUSBDevice: ``` #define kIOUSBDeviceClassName "IOUSBDevice" ``` In macOS Catalina it looks as follows: ``` #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_14 #define kIOUSBDeviceClassName "IOUSBDevice" #define kIOUSBInterfaceClassName "IOUSBInterface" #else #define kIOUSBDeviceClassName kIOUSBHostDeviceClassName #define kIOUSBInterfaceClassName kIOUSBHostInterfaceClassName #endif /* MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_14 */ ``` By default, macOS Catalina uses IOUSBHostDevice. The problem is that using the IOUSBHostDevice class misses some devices. This has been described in 044a7ee commit. To work only with IOUSBDevice, darwin_device_class has been explicitly set to IOUSBDevice. Closes #693 For reference, here's the output of the 'listdevs' example before my changes: 05ac:027b (bus 128, device 2) path: 5 2109:0102 (bus 20, device 6) path: 4 05e3:0751 (bus 20, device 5) path: 1 1a40:0801 (bus 20, device 3) path: 2 0bda:8153 (bus 0, device 2) path: 3 2109:2817 (bus 20, device 1) path: 8 2109:0817 (bus 0, device 1) path: 4 And here's the output after my changes: 05ac:027b (bus 128, device 2) path: 5 2109:0102 (bus 20, device 6) path: 3.2.4 05e3:0751 (bus 20, device 5) path: 3.2.1 1a40:0801 (bus 20, device 3) path: 3.2 0bda:8153 (bus 0, device 2) path: 2.3 2109:2817 (bus 20, device 1) path: 3 2109:0817 (bus 0, device 1) path: 2 Closes #712 Signed-off-by: Nathan Hjelm <hjelmn@google.com>
-
darwin: use GetPipePropertiesV3 on 10.9 and later
Apple added the GetPipePropertiesV3 in IOUSBFamily version 550. The old function appears to be deprecated. When 10.8.x and older are no longer supported the GetPipeProperties call should be removed. Signed-off-by: Nathan Hjelm <hjelmn@google.com>