summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* autobuild: Fix two issuesChris Dickens2020-01-263-4/+4
| | | | | | | | | | | The test for defining the automake conditional for the poll implementation was keying off of the threads variable, producing incorrect results for Cygwin. A simple typo in the Makefile causes a build failure when cross-compiling for Windows. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: Fix build on linuxroot2020-01-262-2/+2
| | | | | | Commit 7bc0ff3 left a parenthesis over which prevents succesful build. Signed-off-by: Andrey Perevortkin <asavah@avh.od.ua>
* core: Convert internal macros to static inline functionsChris Dickens2020-01-2512-82/+145
| | | | | | | | | | | | Older versions of the Visual Studio compiler are picky about macros constructed with the 'do { ... } while (0)' construct. Convert these internal ones to static inline functions. The result is functionally equivalent but gets us type checking and a bit more readability. Also address some compiler warnings due to some header files that are being included in a different order than before. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Fix msvc 2019 project files (internal linkage)winterrace2020-01-247-8/+8
| | | | | | Closes #683 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* linux_usbfs: Clean up inconsistencies and optimize memory usageChris Dickens2020-01-243-571/+539
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The formatting and coding style varied across the whole file. Adopt the following consistent style: - Align function arguments to the opening parenthesis - Do not check for NULL before calling free() - Reduce indentation where possible in loops by continuing in the success case - Remove space between function name and opening parenthesis - Remove pointless pointer casts from void * - Replace comparisons with NULL or 0 by a negation operator - When comparing against rvalues, place the rvalue on the right side of the expression - Where possible, have the debug message string on the same line as the usbi_* call. This makes it easier to grep for specific strings. Also update the definitions in linux_usbfs.h to exactly match that of the kernel and remove definitions that are not needed. A number of functions declared stack buffers of size PATH_MAX. This is generally 4K, which is very much overkill for a lot of the strings and is not friendly for embedded environments. Replace many of these buffers with reasonably-sized ones, in many cases using exactly the size needed. When reading the descriptors during device enumeration, we were starting with a 1K buffer and doubling as needed. The vast majority of devices will not have a large set of descriptors, so change the allocation logic to grow the buffer in steps of 256 bytes. Introduce a new parsing function for reading sysfs attributes. Using the fdopen() function to use fscanf() results in excessive memory allocation, one for the FILE object and another for the buffer into which the C library will read the data. The sysfs attributes of interest are generally just a few characters, so use a small stack buffer and some rigorous parsing to read these attributes. This also consolidates error checking (e.g. negative values or larger than expected values). Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* configure.ac: Cleanup and refactoringChris Dickens2020-01-2415-296/+328
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make the formatting consistent across the entire file. In particular: - Always quote strings whose values are derived - Use tabs consistently - Wrap all arguments with square brackets Replace the use of '-a' with '&&' to be more portable. Rearrange some of the feature checks to be conditional upon the platform or backend. For example, there is no need to check for nfds_t on Windows because poll() doesn't exist there. Similarly we now only check for timerfd on Linux and Solaris. This translates into slightly faster configure times. Explicitly define tokens for both the poll and thread implementations. This makes the preprocessor conditionals much nicer since it is not necessary to enumerate all possible OS_* tokens. Also replace POLL_NFDS_TYPE with a proper typedef that is based on the availability of the nfds_t type. Migrate to config definition names that are more consistent with autoconf. The check for timerfd actually verifies the presence of the library function instead of just the header definitions, and the token USBI_TIMERFD_AVAILABLE is now HAVE_TIMERFD. Similarly the check for syslog results in a definition of HAVE_SYSLOG. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Misc: Clean up zero-length strings and recursion in clock_gettime()Chris Dickens2020-01-244-21/+19
| | | | | | | | | | | | | | Commit 0bf84e4d51 ("core: fix build warning on newer versions of gcc") addressed compiler warnings for zero-length printf format strings in the core library files, but there are some additional remaining in some of the backends. Address these remaining ones in the same manner. Also remove the usbi_dbg() call in netbsd_clock_gettime(). This causes infinite recursion since usbi_dbg() calls the backend's clock_gettime() function. This was similarly addressed for the OpenBSD backend in commit 6acbd8b405 ("Remove infinite recursion in OpenBSD backend"). Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Misc: Cleanup across multiple backendsChris Dickens2020-01-249-201/+36
| | | | | | | | | | | | | | | | | | | Remove the clear_transfer_priv() function from all backends besides Linux. This function is only needed if the backend calls usbi_handle_disconnect(), which only Linux does. Remove the {attach,detach}_kernel_driver() functions from the Darwin backend. They return LIBUSB_ERROR_NOT_SUPPORTED, but the same result is achieved by having those functions be NULL. Remove the init() and exit() functions from the SunOS backend. They are optional and as no-ops are pointless. Remove NULL and 0 initializers from usbi_backend structures. Use named initializers in the NetBSD backend. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Misc: Trim and consolidate header file usageChris Dickens2020-01-2423-277/+149
| | | | | | | | | | | | | Refactor libusbi.h to include the set of common header files needed by every main source file in the library and change these source files to include libusbi.h first, followed by any non-common headers. Including libusbi.h first ensures that the config definitions are pulled in and will eliminate redundant includes in the individual sources files. Also clean up some whitespace errors and remove unnecessary definitions in the manually generated config.h files. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: Make style of debug messages with errno consistent across libraryChris Dickens2020-01-247-54/+53
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* appveyor.yml: Revert back to Visual Studio 2015 imageChris Dickens2020-01-232-7/+4
| | | | | | | | Apparently AppVeyor dropped support for some compilation environments in the 2017 image, so fall back to the 2015 image and forego compilation with the newer tools. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Misc: Use the UNREFERENCED_PARAMETER macro for UNUSED when availableChris Dickens2020-01-222-2/+6
| | | | | | This will squelch compiler warnings if platform headers provide this. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Windows: Improve poll abstractionChris Dickens2020-01-225-338/+336
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 395e5a8a6f ("windows: remove total fds (256) limitations") and commit c730a8410c ("windows: workaround WaitForMultipleObjects max 64 events limitation.") lifted some hard-coded limits in the number of HANDLEs that can be used within the library. This change improves on these changes to make them more efficient. A bitmap has been added to provide an efficient lookup mechanism for located unused file descriptor indices. This avoids the O(n) lookup time for traversing the entire fd_table. This bitmap is dynamically resized along with the fd_table. The incremental size of the fd_table has been reduced from 256 to 64. The vast majority of applications won't need to use 256 HANDLEs, so we can optimize memory usage a bit. Commit fb864b7cde ("fix windows crash when multi-thread do sync transfer") added usbi_inc_fds_ref() and usbi_dec_fds_ref() functions to work around a reference count issue. Remove these functions and change the implementation of usbi_poll() to take a reference to each file descriptor upon entry and drop the references when returning. If the application experiences any kind of crash, there is a problem elsewhere. Finally, make the thread executing usbi_poll() take part in the waiting. The original implementation had this thread simply waiting on a single event while separate threads waited on the HANDLEs. Now this thread will wait on MAXIMUM_WAIT_OBJECTS - 1 HANDLEs, thereby reducing the number of threads that are created. Additionally there is now only a single event object that is shared amongst all waiting threads. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Windows: Add missing '%' character for printf format specifierChris Dickens2020-01-222-3/+3
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Windows: Kill the dedicated thread for monotonic clock_gettime()Chris Dickens2020-01-222-196/+19
| | | | | | | | | | | | | | According to Microsoft, anything prior to Vista could provide inconsistent results for the value of QueryPerformanceCounter() across different cores. Now that XP is no longer supported, we can drop the significant overhead of using a dedicated thread pinned to a single core just to read a timestamp. The C++11 steady_clock implementation directly wraps QueryPerformanceCounter(), so if it is good enough for that then it is good enough for our purposes. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Windows: Fix some MinGW build warnings and printf format specifiersChris Dickens2020-01-214-12/+12
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Windows: Drop support for Windows XPChris Dickens2020-01-2116-151/+50
| | | | | | | | | XP is nearly 20 years old and there are hoops we jump through to keep supporting it. Time to say goodbye and simplify some things. Closes #267 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Windows: Add Visual Studio 2019 supportChris Dickens2020-01-2111-1/+1143
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Misc: Remove obsolete Windows DDK build filesChris Dickens2020-01-2115-548/+9
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Misc: Clean up Visual Studio project filesChris Dickens2020-01-2133-82/+79
| | | | | | | | | | | | | | | | | | | | | | | Commit a9b34d170a ("Adding support for ARM & ARM64 Windows Platform") introduced a dependency on a particular version of the Windows 10 SDK for *all* platforms. This is particularly annoying for most users who will only be building for Windows. Fix this by specifying the SDK dependency only for the ARM/ARM64 platforms and bump to the latest. Commit 77037c4dd6 ("Adds /utf-8 to compile options") added this compiler option to all versions of the Visual Studio project files. This results in a number of warnings with the older versions that don't recognize this option. Fix this by keeping this option only for 2015 and newer. Explicitly specify library dependencies for non-static targets. With a small change in the UsbDk backend we can completely remove all depenencies other than kernel32.lib. Lastly, remove the 'MinimalRebuild' option for 2015 and newer project files as this option is now deprecated and results in a warning for each project. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Windows: Remove support for WinCE and Visual Studio older than 2013Chris Dickens2020-01-20110-13237/+369
| | | | | | | | | | | There appears to be no need for the WinCE backend anymore, and it is increasingly difficult to keep healthy as the rest of the library changes. Require at least Visual Studio 2013 to compile. This simplifies matters as there is some semblance of C99 support there. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* linux_usbfs: Wait until all URBs have been reaped before freeing themChris Dickens2020-01-162-31/+31
| | | | | | | | | | | | | | | | Prior to this change, the URBs allocated for an individual transfer were freed when the last URB in the transfer was reaped. Normally this causes no issues because URBs are reaped in the order they were submitted. If the device is disconnected while multiple URBs are queued, these URBs may be reaped in an order that does not match that of submission. Change the logic to free the URBs when all the URBs of a transfer have been reaped rather than the last one. While in here, improve some debug messages. Closes #607 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: Do not attempt to destroy a default context that doesn't existChris Dickens2020-01-132-6/+12
| | | | | | | | | | Calling libusb_exit(NULL) when a successful call to libusb_init(NULL) has not been made results in a segmentation violation. This is definitely a user error, but we can easily guard against it. Closes #511 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: Fix libusb_get_max_iso_packet_size() for superspeed plusChris Dickens2020-01-132-4/+4
| | | | | | | | | | The current logic fails to consider superspeed plus devices properly. Fix this by checking for superspeed or greater instead of matching against superspeed. Closes #553 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* hotplug: Added libusb_hotplug_get_user_data()gudenau2020-01-134-1/+41
| | | | | | | | | | Closes #380 [dickens] Fixed up API version in doxygen, whitespace issues, function visibility annotation (can't use API_EXPORTED for pointer values) and added new function to libusb-1.0.defs Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Increment LIBUSB_API_VERSION for next releaseChris Dickens2020-01-132-2/+2
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* examples: testlibusb: Always print VID and PID in addition to stringsChris Dickens2020-01-132-27/+16
| | | | | | | | | | | Previously the program would only print the VID when the manufacturer string is unavailable and the PID when the product string is unavailable. Change this to print the VID and PID unconditionally and print the manufacturer and product strings similar to how the serial number string is being printed. In addition, line up the string values with the rest of the output. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* examples: testlibusb: Formatting, whitespace and functional cleanupChris Dickens2020-01-132-97/+84
| | | | | | | | | | | | | | | | | | | | | Make the coding style and whitespace consistent with the rest of the library source code. In the print_device() function, the 'level' argument is unnecessary, so remove it and the associated space padding. Switch to use printf() directly instead of formatting the description into a single buffer. This not only simplifies the code but avoids truncating the description for devices with larger descriptor strings. Make the output formatting consistent by lining up all the printed values and using the same notation for all hexadecimal values. Inspired by PR #452, enable printing all available BOS device capability descriptors, not just the first one. Closes #452 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: fix build warning on newer versions of gccGreg Kroah-Hartman2020-01-134-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | When building libusb on a "newer" version of gcc (9.2), a lot of warnings are thrown about zero-length messages as being part of a format string. An example of this is: descriptor.c:546:11: warning: zero-length gnu_printf format string [-Wformat-zero-length] 546 | usbi_dbg(""); | ^~ Fix this up by replacing all calls of: usbi_dbg(""); with usbi_dbg(" "); as obviously we still want to keep the implicit tracing message in the log. Closes #674 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* windows: relax HCD root hub enumeration errorsJie Zhang2020-01-022-4/+4
| | | | | | | | | | Enumeration errors happen on one HCD root hub should not prevent enumerating other hubs. This will fix an issue seen on some Windows 7 hosts with USB 3.0 host controller. Closes #441, Closes #483 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Change the errcode argument in libusb_strerror to be of type intVladimirTechMan2020-01-023-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | It would be more convenient in practice if the type of error code argument in libusb_strerror was declared as "int", rather than enum libusb_error: In practice, the value for the argument almost always comes from a value returned by libusb function, thus its type is "int" at that point. In which case, depending on the checks enabled when compiling the C or C++ code of applications using libusb's API, every call to libusb_strerror often requires explicit type casting – while not a biggie, it gets inconvenient as the number of logging calls using libusb_strerror grows. It is worth of noting that the "peer" function libusb_error_name already takes the int-type argument, thus eliminating the need in extra value casting. Aligning the signature of libusb_strerror to be the same would also improve the consistency between those two parts of the libusb API. Given that libusb_strerror does a range validation of its argument value, there should not be any real drawbacks or negative effects from "relaxing" the type declaration from enumeration to integer. The existing application code that already does explicit casting to enum, will keep compiling and running like before. Closes #606 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* windows: Translate ERROR_DEVICE_NOT_CONNECTED to LIBUSB_TRANSFER_NO_DEVICEMatthias Bolte2020-01-022-1/+2
| | | | | | | Windows 7 reports error code ERROR_DEVICE_NOT_CONNECTED if transters fail due to unplugging the device. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* windows: Fix USBD_STATUS to LIBUSB_TRANSFER_STATUS translationMatthias Bolte2020-01-024-33/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The MSDN documentaion says that the most significant 4 bits of the USBD_STATUS value indicate success/pending/error state, but then gives them as 2 bit values. The broken translations code assumes these to be the lower 2 bits: 0b0000 for success 0b0001 for pending 0b0010 for error 0b0011 for error But actually it's the higher 2 bits: 0b0000 for success 0b0100 for pending 0b1000 for error 0b1100 for error The USBDK code already deals with USBD_STATUS and gets it correct. Another problem is that the broken translations code then masks off the most significant 4 bits of the USBD_STATUS value, but then compares it to the full 32 bit error codes to figure out the actual error. This switch will always jump to the default case, because all checked error codes have their most significant 2 bits set, but the values they are compared against have those bits masked off. Move the working code from the USBDK backend to the shared header and reuse it in the WinUSB backend too. [dickens] Fixed whitespace, removed unused definitions, add ifdef guard, and retained name as USBD_SUCCESS to match w32api header. Closes #665 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: include sys/time.h on any GNU libc OSPino Toscano2019-12-282-2/+2
| | | | | | | | | | | GNU libc provides sys/time.h, so unconditionally include it when using that libc. Since sys/time.h is already included on a number of OSes, include it to minimize the differences between OSes when using libusb. Arguably, sources using functions from sys/time.h (such as gettimeofday) ought to already include it on their own; OTOH, let's avoid making such issues OS-specific.
* Add Null POSIX backendPino Toscano2019-12-285-4/+196
| | | | | | | Add a simple null backend for POSIX platforms that reports no available devices, and provides no capabilities. Make use of this new backend on all the OSes without an existing backend, so libusb can be built even on OSes without USB support.
* Set project name for doxygenAleksandr Mezin2019-12-222-2/+2
| | | | | | | Currently, generated documentation shows `My Project` as the title: see http://libusb.sourceforge.net/api-1.0/index.html Set it to `libusb`. Signed-off-by: Aleksandr Mezin <mezin.alexander@gmail.com>
* linux_udev: silently ignore "bind" actionJohn Keeping2019-12-032-1/+3
| | | | | | | | | | | | | | | When a driver is bound to a device, udev emits a "bind" action that causes libusb to log an error message: libusb: error [udev_hotplug_event] ignoring udev action bind Since we know this action is not relevant for libusb, silently ignore it to avoid people thinking there is something wrong. There is already a debug log entry for the action, so there is no need to add a duplicate here. Signed-off-by: John Keeping <john@metanate.com>
* Linux: Improved system out of memory handlingSlash Gordon2019-12-032-1/+3
| | | | Maps ENOMEM system error to LIBUSB_ERROR_NO_MEM.
* Linux backend: fix ressource leakLudovic Rousseau2019-11-232-1/+5
| | | | | | | Issue detected by Coverity: 22. leaked_handle: Handle variable fd going out of scope leaks the handle. Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
* Xcode: add tests/stress targetLudovic Rousseau2019-11-012-1/+150
| | | | Also build tests/stress
* Xcode: apply suggested changes from Xcode 11.2Ludovic Rousseau2019-11-012-2/+14
| | | | Enable code signing.
* windows: workaround WaitForMultipleObjects max 64 events limitation.Frank Li2019-10-302-9/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | WaitForMultiObjects have limiation. Only can wait max 64 events. but usbi_poll may pass more than 64 fds. In previous implement, only wait for first 64 events. if previous 64 events were not trigger usbi_poll will wait for about 10s timemout eventhough other event triggered. This patch workaround this limitation. If max events less than 64, call WaitforMultiObjects directly. If max events more than 64, group every 63 events into one work thread. This thread call waitformulitobjects wait for this groug events and one addtional thread exit events. If any events trigger, this thread will trigger main notify events. The main usbi_poll thread call waitforsingleobject wait for notify events. If this events trigger, that means any of work threads get events. Then call exit notify events let all working thread exit safely. Return value changed, 0 means timeout. 1 - N means which event triggered. Closes #612 Signed-off-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Nathan Hjelm <hjelmn@google.com>
* Fix linux_scan_devices() in AndroidVinicius Tinti2019-10-302-2/+2
| | | | | | | | | | | | | Use linux_default_scan_devices() in Android platform. When building for Android the USE_UDEV is false and __ANDROID__ is true resulting in no implementation for linux_scan_devices(). This commit fix it by using linux_default_scan_devices() for Android. Closes #637 Signed-off-by: Vinicius Tinti <vinicius.tinti@almg.gov.br> Signed-off-by: Nathan Hjelm <hjelmn@google.com>
* Solaris: format mismatch in some usbi_dbg()Kenjiro Tsuji2019-10-302-8/+10
| | | | | | | | | | | | | In sunos_usb.c, some usbi_dbg() calls have format mismatch. For example, "%d" is specified for a size_t variable and "%llx" is specified for a uint64_t variable. In LP64 mode, they are format mismatch. For those specifications that are incompatible between ILP32 and LP64, format macros defined in <inttypes.h>, such as PRIuPTR and PRIx64 should be used. Closes #640 Closes #638 Signed-off-by: Nathan Hjelm <hjelmn@google.com>
* Doxygen: do not hardcode the sourceforge.net usernameLudovic Rousseau2019-10-302-2/+2
| | | | | | The username to use to login to web.sourceforge.net should be configured in ~/.ssh/config so that different developers (with different login names) can update the documentation.
* Doxygen: add libusb_wrap_sys_device() in the API listLudovic Rousseau2019-10-302-1/+2
|
* Doxygen: update config file from 1.8.8 to 1.8.16Ludovic Rousseau2019-10-302-181/+378
|
* Solaris backend depends on Solaris private symbolsKenjiro Tsuji2019-09-262-43/+33
| | | | | | | | | | | | | | | | Solaris backend depends on the following double-linked list operation functions from libcmdutils: list_insert_tail, list_create, list_remote_head, list_head, list_next However, they are private symbols in libcmdutils library and moreover libcmdutils library is also a private library. libusb should not directly refer those symbols. Due to this issue, linking a program with libusb fails on the SPARC platform. This issue has been reported as #586. Since the code using those functions is just to build the argument list for execv, the double-linked list operation functions do not need to be used. Closes #627 Signed-off-by: Nathan Hjelm <hjelmn@google.com>
* Solaris: fails to find USB devices on SPARC platformKenjiro Tsuji2019-09-262-5/+10
| | | | | | | | | | | | | | | | | On SPARC platform, libusb fails to find USB devices. sunos_fill_in_dev_info() reads the usb-dev-descriptor property and stores idVendor and idProduct to the dev_sesc structure in little endian. However, when creating a device name for 'match_str' to be specified to sunos_physpath_to_devlink(), it's using the idVendor and idProduct in dev_descr as is without converting them to the host endian, that is big endian for SPARC. As a result, 'match_str' has a wrong device name and sunos_physpath_to_devlink() fails to find the device path corresponding to the USB device. idVendor and idProduct need to be converted to the host endian when creating 'match_str'. This is a fix for #587. Closes #628 Signed-off-by: Nathan Hjelm <hjelmn@google.com>
* Solaris backend is not correctly setting the one transfer mode for ↵Kenjiro Tsuji2019-09-262-28/+43
| | | | | | | | | | | | | | | | | | | | | | | Interrupt-In pipe In sunos_check_device_and_status_open() function, if the target is an Interrupt-In pipe, it opens the status endpoint first and writes USB_EP_INTR_ONE_XFER control to the status endpoint to enable the one transfer mode. And it then closes the status endpoint. After that, it opens the xfer endpoint and re-opens the status endpoint. This is not correct, because closing the status endpoint is implicitly disables the one tranfer mode. As a result, an event notification won't be delivered to the client in timely manner. According to the comment in the source, closing the status endpoint first and opening the xfer endpoint and status endpoint in this order is intentional to avoit an issue that may happen if the USB device has multiple configurations, which may be due to a ugen driver issue. To address both issues, it can open the xfer endpoint first and immediately close it, which will take care of the switch of configurations, if necessary. Then, it can open the status endpoint, enable the one transfer mode, and re-open the xfer endpoint. This is a fix of libusb#620. Closes #629 Signed-off-by: Nathan Hjelm <hjelmn@google.com>