Vianney le Clément de Saint-Marcq [Tue, 13 Dec 2016 15:30:56 +0000 (16:30 +0100)]
linux_usbfs: Get device address from file descriptor
Extend linux_get_device_address() to try to read the device address from
a file descriptor as a last resort, if provided.
Additionally, linux_get_device_address() will now return an error if the
path could not be parsed.
Signed-off-by: Vianney le Clément de Saint-Marcq <code@quartic.eu>
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
Vianney le Clément de Saint-Marcq [Tue, 13 Dec 2016 14:32:39 +0000 (15:32 +0100)]
linux_usbfs: Extract device handle initialization from op_open()
Slightly refactor op_open() to extract the device handle initialization
code into a new initialize_handle() function, similar to the
initialize_device() function.
Signed-off-by: Vianney le Clément de Saint-Marcq <code@quartic.eu>
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
Vianney le Clément de Saint-Marcq [Tue, 13 Dec 2016 12:57:25 +0000 (13:57 +0100)]
linux_usbfs: Fallback to usbfs if device has no sysfs_dir
Handle devices that are initialized with NULL as sysfs_dir. For such
devices, the usbfs functions should be used instead of their sysfs
counterparts.
Signed-off-by: Vianney le Clément de Saint-Marcq <code@quartic.eu>
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
Sean McBride [Sat, 15 Dec 2018 21:26:14 +0000 (16:26 -0500)]
Tried to untangle mixing of int, enum libusb_error, kern_return_t, and IOReturn.
- Replace all kern_return_t with IOReturn, they are basically the same, but IOReturn is more common in IOUSBLib
- improve consistency by using the name 'kresult' for all IOReturn-type results, and not using that name for libusb_error return values.
- changed a few functions to use real 'bool' (this file already uses C99)
- replaced some raw '0's with LIBUSB_SUCCESS or kIOReturnSuccess.
- replaced some raw 'int's with either IOReturn or enum libusb_error.
- replaced ambiguous "if (kresult)" with more explicit "if (kresult != kIOReturnSuccess)"
- replaced incorrect use of darwin_to_libusb with darwin_transfer_status
Most of these were found by increasing the compiler warning level.
Closes #510
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
Sean McBride [Sat, 15 Dec 2018 21:12:07 +0000 (16:12 -0500)]
Removed unneeded checks for passing null to free()
Closes #507
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
Sean McBride [Sat, 15 Dec 2018 21:03:17 +0000 (16:03 -0500)]
Added USBI_PRINTFLIKE to allow finding printf format string mistakes
Fixed one such misktake
Closes #506
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
Stephen [Mon, 17 Dec 2018 19:42:33 +0000 (11:42 -0800)]
use travis homebrew addon for reliability
Closes #513
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
Nathan Hjelm [Wed, 5 Dec 2018 17:52:08 +0000 (10:52 -0700)]
Bump libusb API version for next release
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Nathan Hjelm [Wed, 5 Dec 2018 17:36:50 +0000 (10:36 -0700)]
configure.ac: bump .so version for next release
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Nathan Hjelm [Wed, 5 Dec 2018 17:36:20 +0000 (10:36 -0700)]
Update ChangeLog
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Alexander Pyhalov [Thu, 24 May 2018 12:03:45 +0000 (15:03 +0300)]
usbi_dbg() uses backend's clock_gettime(), break recursion in sunos backend
Closes #431
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Victor Toso [Tue, 7 Aug 2018 07:45:58 +0000 (09:45 +0200)]
examples: Fix format-truncation on debug
As description is used only for debug, we can extend it to be sure to
fit 256 from string variable plus 3 chars from " - " as described in
gcc warning below
| testlibusb.c: In function ‘print_device.constprop’:
| testlibusb.c:188:51: warning: ‘ - ’ directive output may be truncated writing 3 bytes into a region of size between 1 and 256 [-Wformat-truncation=]
| snprintf(description, sizeof(description), "%s - ", string);
| ^~~
| testlibusb.c:188:5: note: ‘snprintf’ output between 4 and 259 bytes into a destination of size 256
| snprintf(description, sizeof(description), "%s - ", string);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Closes #460
Signed-off-by: Victor Toso <victortoso@redhat.com>
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Alexander Pyhalov [Thu, 24 May 2018 11:55:20 +0000 (14:55 +0300)]
Enable timerfd on sunos when available
Closes #432
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
gudenau [Wed, 20 Jun 2018 01:12:52 +0000 (20:12 -0500)]
Add missing libusb_exit on an error condition
Closes #448
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Bence Cs [Wed, 7 Nov 2018 12:17:40 +0000 (13:17 +0100)]
Hungarian translation
Closes #493
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
saur0n [Tue, 27 Nov 2018 17:52:12 +0000 (20:52 +0300)]
Fixed typo in the documentation
Closes #496
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
dmitrykos [Tue, 23 Oct 2018 18:05:25 +0000 (21:05 +0300)]
core: new API libusb_set_log_cb() to redirect global and per context log messages to the provided log handling function
Closes #486
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Nathan Hjelm [Mon, 22 Oct 2018 20:04:04 +0000 (14:04 -0600)]
update nano
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Alexander Schlarb [Mon, 18 Jun 2018 13:11:40 +0000 (15:11 +0200)]
Add German translation
Most strings were copied from the german `strerror` output on equivallent `errno` values and then adapted as necessary.
Closes #446
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Baruch Siach [Tue, 5 Jun 2018 11:22:21 +0000 (14:22 +0300)]
configure.ac: fix detection of clock_gettime library
glibc before 2.17 requires link with librt for clock_gettime(). The
AC_SEARCH_LIBS check in configure.ac should detect this dependency.
Unfortunately commit
cb77a25e51 (configure.ac: Remove obsolete AC_ERROR
and make formatting consistent) inadvertently renamed to clock_gettime2,
thus breaking librt detection.
Restore the correct clock_gettime() name.
Closes #439
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Nathan Hjelm [Wed, 17 Oct 2018 18:02:14 +0000 (12:02 -0600)]
os/darwin: remove code that changed the device class used
To support macOS El Capitan I added some code to change from using the
IOUSBDevice class to using IOUSBHostDevice. This looked necessary as
Apple had re-writed IOUSBFamily and IOUSBHostDevice was the new base
class name. The problem is that using the new class misses some
devices in more recent versions of macOS. Apple is still including the
IOClassNameOverride property (as of macOS Mojave) so it is still safe
to search using the IOUSBDevice class. We will need to find a
different class if Apple ever removes the IOClassNameOverride
property from USB devices.
Closes #428
Signed-off-by: Nathan Hjelm <hjelmn@mac.com>
Nathan Hjelm [Thu, 26 Jul 2018 18:48:07 +0000 (12:48 -0600)]
os/darwin: switch from using ResetDevice to USBDeviceReEnumerate
In newer versions of macOS the ResetDevice function does nothing. For
these systems we have to use USBDeviceReEnumerate. This should also
work for older versions os MacOS X.
Fixes #455
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Stephen [Fri, 30 Mar 2018 14:09:09 +0000 (07:09 -0700)]
Move to brew bundle
improved dependency management with brew bundle
Chris Dickens [Sun, 25 Mar 2018 00:43:43 +0000 (17:43 -0700)]
libusb 1.0.22
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Sun, 25 Mar 2018 00:42:46 +0000 (17:42 -0700)]
examples: testlibusb: Fix DDK build warning
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Tue, 20 Mar 2018 17:01:48 +0000 (10:01 -0700)]
Windows: Add back resource and definition files to VS DLL projects
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Sat, 17 Mar 2018 07:21:14 +0000 (00:21 -0700)]
libusb 1.0.22-rc4
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Sat, 17 Mar 2018 07:15:20 +0000 (00:15 -0700)]
Windows: WinUSB: Allow caching config descriptors to fail
Certain buggy devices may not provide all the advertised configuration
descriptors. Prior to this commit, failure to cache any one of the
descriptors would result in all of the descriptors being freed and the
device being inaccessible. Work around this by continuing on if fetching
a configuration descriptor fails. The device may still be usable if the
descriptor for the current configuration was successfully retrieved.
Closes #390
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Mon, 12 Mar 2018 17:39:26 +0000 (10:39 -0700)]
Windows: Restructure DDK/MSVC project files
For simplicity and to address some build warnings, this commit reworks
the project files to eliminate duplication and consolidate common build
flags and options. Also adds the stress and testlibusb projects to the
DDK build script.
Closes #402
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Mon, 12 Mar 2018 17:28:40 +0000 (10:28 -0700)]
Windows: WinUSB: Guard against erroneous reporting of devices
During enumeration, obtaining the port number via SPDRP_ADDRESS might
return a bogus value for some third-party HCD drivers. If this occurs,
we might end up reporting the device as having the VID/PID from the last
successful enumeration. Guard against this particular situation by
clearing the USB_NODE_CONNECTION_INFORMATION_EX structure before issuing
the DeviceIoControl() call.
References #403
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Mon, 12 Mar 2018 17:25:02 +0000 (10:25 -0700)]
Windows: UsbDk: Fix potential buffer overflow
Closes #397
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Mon, 12 Mar 2018 17:24:04 +0000 (10:24 -0700)]
Windows: WinUSB: Do not assume that driver implements CancelIoEx()
Cancelling an individual OVERLAPPED I/O operation is something that a
driver can optionally implement. It appears that the native WinUSB
driver supports this but libusbK does not. Therefore we will attempt
to use it and fall back to the AbortPipe() call if an error occurs.
Closes #400
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Mon, 12 Mar 2018 16:54:33 +0000 (09:54 -0700)]
Windows: Plug HANDLE leak
Restore a CloseHandle() call that was mistakenly removed during a merge
conflict resolution.
Closes #404
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Sat, 24 Feb 2018 10:02:34 +0000 (02:02 -0800)]
libusb 1.0.22-rc3
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Sat, 24 Feb 2018 10:02:03 +0000 (02:02 -0800)]
Windows: UsbDk: Implement get_config_descriptor_by_value()
This fixes a NULL pointer dereference when the user selects the UsbDk
backend and subsequently calls libusb_get_config_descriptor_by_value().
Closes #395
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
zachary [Sat, 10 Feb 2018 08:59:49 +0000 (16:59 +0800)]
Windows: Fix hid_abort_transfers blocking
Closes #392
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Patrick Stewart [Wed, 31 Jan 2018 15:18:06 +0000 (15:18 +0000)]
Windows: Fix race condition between submit and handle events
Check the event object for completion in poll instead of using
HasOverlappedIoCompleted. When we submit a transfer on Windows the fd is
added to the poll list before the read/write begins, so
HasOverlappedIoCompleted can be called before overlapped.Internal is set
to ERROR_IO_PENDING if events are being being handled concurrently, so
the fd will be marked as completed before it has actually started.
[dickens] Instead of replacing HasOverlappedIoCompleted, supplement it
so that it can provide a fast path to avoid WaitForSingleObject() in
the general case
Closes #386, Closes #387
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 2 Feb 2018 07:31:18 +0000 (23:31 -0800)]
Windows: Always search for "USB" PnP enumerator class
On systems running Windows 7 and earlier that only have a USB 3.0 host
controller, devices may not be listed correctly if the root hub PnP
enumerator is anything other than "USB". This regression was introduced
in the recent enumeration refactoring (commit
71a779d07).
Closes #385
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Sun, 28 Jan 2018 01:29:46 +0000 (17:29 -0800)]
libusb 1.0.22-rc2
Chris Dickens [Sun, 28 Jan 2018 01:27:53 +0000 (17:27 -0800)]
Windows: Regenerate libusb-1.0.def file from latest DLL
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Sun, 28 Jan 2018 00:22:10 +0000 (16:22 -0800)]
Windows: Check composite interfaces before calling functions
Commit
c4438b3c introduced a regression by failing to check for the
presence of a function in the backend when called on a composite device.
Fix this by introducing a new helper macro and checking for function
pointers at all necessary locations.
Closes #383
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Tue, 9 Jan 2018 07:08:47 +0000 (23:08 -0800)]
libusb 1.0.22-rc1
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sean McBride [Fri, 5 Jan 2018 03:17:24 +0000 (22:17 -0500)]
darwin: Improve error checking to prevent (very unlikely) null dereference
Defend against the very unlikely possibility of CFNumberCreate() returning null.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sean McBride [Fri, 5 Jan 2018 03:16:03 +0000 (22:16 -0500)]
darwin: Suppress deprecation warning when building against 10.13 SDK
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sean McBride [Mon, 8 Jan 2018 21:57:50 +0000 (16:57 -0500)]
darwin: Test use of kUSBDeviceSpeedSuper against SDK version
Closes #362
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sean McBride [Sat, 30 Dec 2017 01:31:56 +0000 (20:31 -0500)]
darwin: extend enum libusb_speed for 10000MBit/s case
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Tue, 9 Jan 2018 06:04:56 +0000 (22:04 -0800)]
linux_usbfs: Add support for reporting super speed plus devices
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Tue, 9 Jan 2018 06:03:49 +0000 (22:03 -0800)]
core: Add definition for LIBUSB_SUPER_SPEED_PLUS (10Gb/s)
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Joshua Blake [Sat, 30 Nov 2013 11:18:29 +0000 (06:18 -0500)]
Windows: Added isochronous support via libusbk
[dickens] Rebased against latest changes and fixed some styling issues
Closes #246
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Tue, 9 Jan 2018 04:41:50 +0000 (20:41 -0800)]
Fix appveyor scripts for Cygwin and MinGW to build as intended
The sub-directory created to store the generated files and build objects
was not being used as intended, because each invocation of the bash
starts in the home directory. Fix this by changing to the intended
directory prior to each command invocation.
Also replace the invocation of autogen.sh with bootstrap.sh, since using
autogen.sh calls ./configure and we weren't using the results of that
work. Instead we call configure directly from the sub-directory while
enabling the examples and test builds (for Cygwin) as autogen.sh would do.
Also fix the invalid value for the --build option provided to the x64
build of MinGW.
Finally, propagate errors from each script command so that failures are
caught and reported.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Mon, 8 Jan 2018 20:31:55 +0000 (12:31 -0800)]
Windows: Fix MinGW build warnings/errors
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sean McBride [Fri, 29 Dec 2017 18:30:24 +0000 (13:30 -0500)]
core: Fixed clang -Wcomma warning
Fixes:
descriptor.c:1179:13: Possible misuse of comma operator here
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sean McBride [Fri, 29 Dec 2017 18:25:42 +0000 (13:25 -0500)]
darwin: Changed weirdo fixed-sized typedefs with the usual IOUSBLib.h ones
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sean McBride [Fri, 29 Dec 2017 18:23:51 +0000 (13:23 -0500)]
darwin: Untangle clock_* API tests from atomics tests
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sean McBride [Fri, 29 Dec 2017 18:23:00 +0000 (13:23 -0500)]
darwin: Replaced low-level mach API with pthread API
Found this because clang was warning that the return value was being
converted from unsigned to signed.
The need for a mach API surprised me, and I found this alternative
formulation in a Chromium bug:
https://groups.google.com/forum/#!topic/native-client-reviews/z---hlHbQNc
which describes: "mach_thread_self() needs to be balanced by mach_port_deallocate(),
which is two system calls. pthread_mach_thread_np(pthread_self()) is two libc
function calls and no system calls, because pthread caches the Mach port."
Fixed the conversion warning too, with a cast.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sean McBride [Fri, 29 Dec 2017 18:15:07 +0000 (13:15 -0500)]
darwin: Cleanup and fixes related to Mac OS IOUSBLib interface checks
- revisited fix to issue #48:
- guard kIOUSBDeviceInterfaceID500 with 10.8 deployment (not 10.9).
I believe a typo in the bug report caused this to be guarded too
strictly.
- added deployment target tests to every interface check. Necessary
because merely checking for a macro definition tells us nothing
about what features are available at runtime. It is common to build
against new SDKs but deploy to older OSes.
- properly guard kIOUSBInterfaceInterfaceID700 against 10.10 deployment
(not 10.9). It was added in 10.10. Probably a copy-pasto.
- changed non-existent kIOUSBDeviceInterfaceID220 to
kIOUSBDeviceInterfaceID197. Probably a copy-pasto.
- don't use defines like MAC_OS_X_VERSION_10_9 since they don't exist in
older SDKs and would fail to compile, use raw numbers instead.
- added tests for newer interfaces: kIOUSBInterfaceInterfaceID800,
kIOUSBInterfaceInterfaceID650, kIOUSBDeviceInterfaceID650.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sean McBride [Fri, 29 Dec 2017 18:02:05 +0000 (13:02 -0500)]
Added some Xcode-related items to .gitignore
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sean McBride [Fri, 29 Dec 2017 17:57:26 +0000 (12:57 -0500)]
darwin: Configure Xcode project to specify tab/space, indent amount
All source files are now tagged as using tabs of 4 spaces, except
darwin_usb.c and darwin_usb.h which use spaces of 2 spaces. This allows
editing files in Xcode without it messing up any particular files.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sean McBride [Fri, 29 Dec 2017 17:50:15 +0000 (12:50 -0500)]
Misc: Replace "Mac OS X" with "macOS", its current name
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sameeh Jubran [Sun, 15 Jan 2017 09:40:57 +0000 (11:40 +0200)]
Windows: Ditch UsbDk build configuration
Previous patch introduced run-time UsbDk backend activation,
therefore separate build configuration is not needed anymore.
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Chris Dickens [Mon, 8 Jan 2018 18:17:26 +0000 (10:17 -0800)]
Windows: Enable dynamic selection between WinUSB and UsbDk backends
This commit unifies the two Windows backends into a single project and
enables the user to switch to the UsbDk backend, if available, using the
libusb_set_option() function. All contexts will use the WinUSB backend
by default for backwards compatibility.
With this change, the UsbDk-specific projects are no longer required.
Closes #309
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Sun, 7 Jan 2018 05:43:12 +0000 (21:43 -0800)]
Windows: Rework poll() emulation to a much simpler and effective design
The previous poll() implementation worked okay but had some issues. It
was inefficient, had a large footprint, and there were simply some use
cases that didn't work (e.g. a synchronous transfer that completes when
no other event or transfer is pending would not be processed until the
next poll() timeout).
This commit introduces a new, simpler design that simply associates an
OVERLAPPED structure to an integer that acts as a file descriptor. The
poll() emulation now solely cares about the OVERLAPPED structure, not
transfers or HANDLEs or cancelation functions. These details have been
moved up into the higher OS-specific layers.
For Windows NT environments, several deficiencies have been addressed:
1) It was previously possible to successfully submit a transfer but fail
to add the "file descriptor" to the pollfd set. This was silently
ignored and would result in the user never seeing the transfer being
completed.
2) Synchronously completed transfers would previously not be processed
unless another event (such as a timeout or other transfer completion)
was processed.
3) Canceling any one transfer on an endpoint would previously result in
*all* transfers on that endpoint being canceled, due to the use of
the AbortPipe() function.
This commit addresses all of these issues. In particular, run-time
detection of the CancelIoEx() function will allow the user to cancel a
single outstanding transfer without affecting any others still in
process.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Sun, 7 Jan 2018 05:32:23 +0000 (21:32 -0800)]
Windows: Add check for ERROR_FILE_NOT_FOUND, which means device removed
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 23:49:58 +0000 (15:49 -0800)]
Windows: UsbDk: Fix some minor style/naming issues
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 23:47:27 +0000 (15:47 -0800)]
Windows: UsbDk: Return appropriate error code for malloc failure
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 23:45:18 +0000 (15:45 -0800)]
Windows: UsbDk: Fix direction determination for control transfers
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 23:35:26 +0000 (15:35 -0800)]
Windows: UsbDk: Remove unnecessary empty functions
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 23:32:16 +0000 (15:32 -0800)]
Windows: UsbDk: Cache system redirector handle
This handle is needed for each transfer submission, so eliminate
repeated calls to obtain the handle by caching it during open.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 23:23:06 +0000 (15:23 -0800)]
Windows: UsbDk: Use a better macro for getting context
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 23:16:19 +0000 (15:16 -0800)]
Windows: UsbDk: Fix spelling of InterruptTransferType enum
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 23:22:10 +0000 (15:22 -0800)]
Windows: UsbDk: Fix some strange type-casting
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 07:44:57 +0000 (23:44 -0800)]
Misc: Add TargetName to getopt VS project files to supress warning
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 07:33:09 +0000 (23:33 -0800)]
Misc: Sort projects alphabetically in VS solution files
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 07:32:33 +0000 (23:32 -0800)]
Misc: Fix references section in fxload VS project files
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 07:32:14 +0000 (23:32 -0800)]
Misc: Fix linker options in getopt VS project files
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 07:21:48 +0000 (23:21 -0800)]
Misc: Add missing files to VS2005 projects for libusb
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 07:19:47 +0000 (23:19 -0800)]
Misc: Fix minor discrepancies in WinCE MSVC files
Add missing header files, fix preprocessor definitions for static
library, and sort projects and files by name.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 05:55:01 +0000 (21:55 -0800)]
WinCE: Give a variable a more appropriate name, matching other patterns
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 05:54:01 +0000 (21:54 -0800)]
WinCE: Remove empty function for unsupported ISO transfers
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 05:51:04 +0000 (21:51 -0800)]
WinCE: Add back mistakenly removed errno variable
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 5 Jan 2018 00:37:09 +0000 (16:37 -0800)]
Windows: Rework WinUSB enumeration process to fix issues on Win8+
As they sometimes do, Microsoft made changes to the way in which the
SetupAPI functions list the devices returned by SetupDiGetClassDevs().
In particular, composite devices started returning their interfaces
before the parent device, which caused some issues with the way the
enumeration logic was assigning things. For composite devices, it
appears that the first interface behaves much like the parent device in
some regards, so the library was creating a device specifically for the
first interface and then again when the actual parent device was
encountered. This caused composite devices to appear in the device list
twice, with the first instance being unusable for most operations.
This commit significantly changes the way in which the enumeration
process is done. Previously we would scan for HCDs, hubs, and generic
devices, in that order and in distinct passes (obtaining a new listing
of devices from SetupAPI). Now we will obtain a single snapshot at the
beginning of the enumeration process and iterate through this to scan
for each type of device.
With a single snapshot, we can be assured that the device instance
handle will not change between passes and thus we can use this as the
unique identifier. This completely removes the need to hash the device
instance ID to obtain a unique identifier and simplifies the process.
The previous enumeration process also created "dummy" libusb_device
instances for the HCDs that were never exposed to the user. This has
been removed in favor of identifying which of the encountered hubs are
actually root hubs.
Finally, the query for the port number has been moved to the GENeric
pass at the point where the devices are actually initialized. This query
operation has been relaxed to allow failure, since some virtual USB
devices don't properly implement this query in their drivers.
Closes #215, Closes #251, Closes #257, Closes #288
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Thu, 4 Jan 2018 23:52:56 +0000 (15:52 -0800)]
Windows: Remove port member from device's private structure
The libusb_device structure already has a port_number member that stores
the same information, so don't duplicate this elsewhere.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Thu, 4 Jan 2018 23:45:07 +0000 (15:45 -0800)]
Windows: Be a bit smarter when setting composite interfaces
Instead of open-coding the search for the "MI_" substring, use the
strstr() function to find the string and verify that the following two
characters are indeed digits.
Also guard against the possibility of the interface number being larger
than what we can support.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Thu, 4 Jan 2018 21:47:34 +0000 (13:47 -0800)]
POSIX: Improve threading abstraction as done in
f06c4f5b
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Thu, 4 Jan 2018 21:42:52 +0000 (13:42 -0800)]
Windows: Further improve thread abstraction
Adopt typedefs and inline functions to get the benefits of type checking.
Convert all trivial functions to inline and remove return values where
they aren't checked.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Thu, 4 Jan 2018 07:12:50 +0000 (23:12 -0800)]
Windows: Constify variables that aren't supposed to change
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Thu, 4 Jan 2018 07:09:09 +0000 (23:09 -0800)]
Windows: Kill empty functions and switch to runtime checking
Instead of requiring each driver API to provide a complete set of
functions, some of which may be simple containers for returning an
unsupported error code, allow function pointers to be NULL and return
an error when a NULL pointer is encountered.
Also remove the unused sub_api parameter from the API init/exit
functions.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Thu, 4 Jan 2018 07:02:00 +0000 (23:02 -0800)]
Windows: Remove unused DLL functions and header definitions
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Thu, 4 Jan 2018 06:43:56 +0000 (22:43 -0800)]
Windows: Fix some minor style issues
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Thu, 4 Jan 2018 05:18:02 +0000 (21:18 -0800)]
Windows: Improve locking in threading abstraction
Convert the usbi_mutex_t type to a CRITICAL_SECTION object. There
are numerous advantages including lower resource usage and a better
fast-path (doesn't require entering kernel space).
Simplify the condition variable implementation by not associating a
wait structure with a particular thread ID. This is not needed and
causes an unnecessary search through the linked list of any available
wait structures when the real optimization is just reusing an already
created event object.
Also, while here remove all the checks for NULL pointers because we
don't do such a silly thing inside the library.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Thu, 4 Jan 2018 03:19:39 +0000 (19:19 -0800)]
Misc: Ensure that both WINVER and _WIN32_WINNT are defined for Windows builds
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Wed, 3 Jan 2018 21:53:56 +0000 (13:53 -0800)]
Windows: Improve enumeration process
Prior to this commit, there were some limitations and inefficiencies
during the enmeration process.
First, the maximum number of device interface GUIDs that could be
enumerated was fixed at 64. This limit has been removed and the list
of GUIDs is dynamically resized as new ones are encountered. Logic has
also been added to detect the presence of duplicate GUIDs in order to
speed up the enumeration process.
Next, when searching for device interface GUIDs, only the
"DeviceInterfaceGUIDs" registry key was being consulted. Now we will
also consider "DeviceInterfaceGUID" in order to support devices that
have the GUID listed under this key (such as some WCID devices).
Finally, there used to be a static list of USB PnP enumerator strings
that were used to detect devices during the GENeric enumeration pass. In
many cases, this is wasteful as these enumerators are only present with
very specific hardware. To improve this, we now keep track of the USB
PnP enumerator string encountered as we enumerate the hubs. This allows
the enumeration process to only search for devices that could possibly
be present on the system given the hardware and drivers that were
encountered.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Wed, 3 Jan 2018 21:53:25 +0000 (13:53 -0800)]
Windows: Kill perpetually growing list of hub driver names
During enumeration, it is unnecessary to match a hub against a list of
known driver names because hubs are enumerated with a specific device
interface GUID. This will eliminate the need for further expansions to
the hub driver list as manufacturers release new drivers.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 29 Dec 2017 06:52:36 +0000 (22:52 -0800)]
Misc: Add _CRT_SECURE_NO_WARNINGS to testlibusb to suppress warning C4996
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Chris Dickens [Fri, 29 Dec 2017 06:51:28 +0000 (22:51 -0800)]
hotplug: Cast ssize_t to int in error path to avoid compiler warning
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sean McBride [Thu, 28 Dec 2017 04:55:34 +0000 (23:55 -0500)]
WinCE: Fixed incorrect check of return value, found by cppcheck
cppcheck was warning:
nullPointerRedundantCheck,libusb/os/wince_usb.c:280,warning,Either the condition '!discdevs' is redundant or there is possible null pointer dereference: discdevs.
In fact, the issue was just checking the wrong thing.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sean McBride [Thu, 28 Dec 2017 04:53:27 +0000 (23:53 -0500)]
Fixed various trivial cppcheck 1.80 warnings
Specifically:
redundantAssignment,examples/dpfp.c:422,style,Variable 'r' is reassigned a value before the old one has been used.
redundantAssignment,libusb/os/threads_posix.c:64,style,Variable 'ret' is reassigned a value before the old one has been used.
unreadVariable,libusb/os/netbsd_usb.c:217,style,Variable 'hpriv' is assigned a value that is never used.
unreadVariable,libusb/os/netbsd_usb.c:235,style,Variable 'hpriv' is assigned a value that is never used.
unreadVariable,libusb/os/openbsd_usb.c:251,style,Variable 'hpriv' is assigned a value that is never used.
unreadVariable,libusb/os/openbsd_usb.c:275,style,Variable 'hpriv' is assigned a value that is never used.
unsignedLessThanZero,libusb/os/windows_winusb.c:259,style,Checking if unsigned variable '_index' is less than zero.
unsignedLessThanZero,libusb/os/windows_winusb.c:298,style,Checking if unsigned variable '_index' is less than zero.
unsignedLessThanZero,libusb/os/windows_winusb.c:367,style,Checking if unsigned variable '_index' is less than zero.
invalidPrintfArgType_sint,examples/xusb.c:534,warning,%d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sean McBride [Thu, 28 Dec 2017 04:35:42 +0000 (23:35 -0500)]
Removed accidental double semi colons at end of line
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sean McBride [Thu, 28 Dec 2017 03:42:28 +0000 (22:42 -0500)]
core: Fixed deprecated attribute to work on clang
clang was warning:
core.c:2011:5: Declaration is marked with '\deprecated' command but
does not have a deprecation attribute
This was because LIBUSB_DEPRECATED_FOR was checking for gcc >= 4.5
whereas clang identifies itself as gcc 4.2. So fallback to
__attribute__((deprecated)) without a message string on older GCCs
(and thus clang).
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Sean McBride [Thu, 28 Dec 2017 03:34:22 +0000 (22:34 -0500)]
examples: xusb: replaced insecure sprintf with snprintf
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>