platform/upstream/libusb.git
7 years agoExamples: Ported testlibusb from libus-0.1 to libusb-1.0
Anil Nair [Sat, 2 Apr 2016 00:59:11 +0000 (06:29 +0530)]
Examples: Ported testlibusb from libus-0.1 to libusb-1.0

This commit is based on Nathan's branch
https://github.com/hjelmn/libusb-darwin/blob/master/examples/testlibusb1.c

Closes #178

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agoAdd support for Intel Alpine Ridge USB 3.1 Controller on Windows 7.
Jeffrey Nichols [Mon, 21 Mar 2016 17:53:11 +0000 (13:53 -0400)]
Add support for Intel Alpine Ridge USB 3.1 Controller on Windows 7.

Closes #176

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows: Clean up referenced devices when memory allocation fails
Chris Dickens [Mon, 30 May 2016 02:44:29 +0000 (19:44 -0700)]
Windows: Clean up referenced devices when memory allocation fails

Similar to commit adb6e39b68699b5d849836f9aaff7640b0f16173, drop the
use of usbi_reallocf() as the memory would be freed, thereby leaking
device references.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoClean failure in discovered_devs_append.
FTDI Dev [Wed, 2 Mar 2016 16:29:27 +0000 (16:29 +0000)]
Clean failure in discovered_devs_append.

Closes #161

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoMisc: Fix usbi_os_backend structure initialization
Chris Dickens [Mon, 30 May 2016 02:51:48 +0000 (19:51 -0700)]
Misc: Fix usbi_os_backend structure initialization

Backends not using named initializers were broken by the recent
addition of commit a283c3b5a3dce8f6f33331b9aa1d95d41c8f241c.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoMisc: Add .amend to .gitignore
Chris Dickens [Mon, 30 May 2016 02:19:51 +0000 (19:19 -0700)]
Misc: Add .amend to .gitignore

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoAdd support for persistent device memory.
Steinar H. Gunderson [Sat, 20 Feb 2016 11:26:12 +0000 (12:26 +0100)]
Add support for persistent device memory.

Add a function to allocate memory belonging to a specific device,
so that the operating system can DMA straight into it for zerocopy,
and also avoid some clearing. Also, this allows up-front memory
allocation in the kernel at program startup; memory allocation is
otherwise done per-transfer, which can fail in a system where memory has become
fragmented over time).

This mirrors new functionality going into Linux' USB stack (recently
reviewed and acked upstream); only Linux is supported as a backend
currently.

[Chris Dickens] Modified to fix doxygen documentation, correct parameter
naming, reposition function declarations, and address a missing request
during the patch review process.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows: Fix false assertion failure message during enumeration
Chris Dickens [Mon, 30 May 2016 00:35:09 +0000 (17:35 -0700)]
Windows: Fix false assertion failure message during enumeration

Commit 1d54ee1b6687c532eca75925f56eb12e2a34ce42 addressed a device
reference leak but introduced a false warning message that occurs
for devices detected in early enumeration passes (e.g. hubs). The
assertion is meant to warn of a mismatch between parent devices but
fails to account for the fact that some devices that are allocated
early do not have a parent device assigned until the later
enumeration passes.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoAUTHORS: update my copyright
Nathan Hjelm [Sun, 20 Mar 2016 15:48:06 +0000 (09:48 -0600)]
AUTHORS: update my copyright

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agoAppVeyor: add cygwin and minGW support
hacker2490 [Thu, 3 Mar 2016 11:31:37 +0000 (17:01 +0530)]
AppVeyor: add cygwin and minGW support

- Changes in platform configuration, x86 breaks the build
- Solution file does not contain platform for Any CPU, fixing it to Win32
- Added Multiple solutions to appveyor configuration file
- Added batch script for VS2010 builds
- Added fixes to appveyor.bat file and appveyor.yml
- Fixes for Platform and Configuration in appveyor.bat
- Fixed windows exit code, Appveyor reports exit on succesful build
- Multiple Builds in same platform and configuration, fixed it
- Added appveyor configuration to compile using MinGW 32-bit and 64-bits
- Minor Fixes for batch file and Added cygwin build script

Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
8 years agofix nano version
Nathan Hjelm [Sat, 12 Mar 2016 14:31:45 +0000 (07:31 -0700)]
fix nano version

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agoautogen: remove --enable-maintainer-mode
Nathan Hjelm [Sat, 12 Mar 2016 14:29:55 +0000 (07:29 -0700)]
autogen: remove --enable-maintainer-mode

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agoconfigure: bump autoconf version and remove obsolete AM_MAINTAINER_MODE
Nathan Hjelm [Thu, 10 Mar 2016 19:57:50 +0000 (12:57 -0700)]
configure: bump autoconf version and remove obsolete AM_MAINTAINER_MODE

This commit bumps the minimum autoconf version to 2.69. This only
affects maintainers and will ensure libusb tarballs have up-to-date
configure scripts. At the same time we are removing the
AM_MAINTAINER_MODE macro as even its creator recommends against
using it.

Closes #122

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agocore: re-add one more conditional
Nathan Hjelm [Sun, 6 Mar 2016 22:04:02 +0000 (15:04 -0700)]
core: re-add one more conditional

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agocore: revert some of prior patch
Nathan Hjelm [Sun, 6 Mar 2016 22:00:31 +0000 (15:00 -0700)]
core: revert some of prior patch

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agoREADME.md: update AppVeyor badge (again)
Ludovic Rousseau [Sun, 6 Mar 2016 21:51:46 +0000 (22:51 +0100)]
README.md: update AppVeyor badge (again)

Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
8 years agofree can handle NULL ptr.
Gaurav [Fri, 19 Jun 2015 03:23:59 +0000 (08:53 +0530)]
free can handle NULL ptr.

free(NULL) is no operation.

Contributed by @ya1gaurav.

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agoAppVeyor: use a .bat file now
hacker2490 [Thu, 3 Mar 2016 11:31:37 +0000 (17:01 +0530)]
AppVeyor: use a .bat file now

- Changes in platform configuration, x86 breaks the build
- Solution file does not contain platform for Any CPU,fixing it to Win32
- Added Multiple solutions to appveyor configuration file
- Added batch script for VS2010 builds
- Added fixes to appveyor.bat file and appveyor.yml
- Fixes for Platform and Configuration in appveyor.bat
- Fixed windows exit code, Appveyor reports exit on succesful build
- Multiple Builds in same platform and configuration,fixed it

8 years agoandroid: update README
William Skellenger [Sun, 3 Jan 2016 22:04:54 +0000 (17:04 -0500)]
android: update README

Added other $ARCH

Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
8 years agoandroid: Fix typo in README
William Skellenger [Mon, 4 Jan 2016 02:46:50 +0000 (21:46 -0500)]
android: Fix typo in README

Remove the /sdcard copy and not the /system/lib copy

Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
8 years agoREADME.md: update AppVeyor badge
Ludovic Rousseau [Sun, 6 Mar 2016 20:37:00 +0000 (21:37 +0100)]
README.md: update AppVeyor badge

Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
8 years agoexamples: fix 3 compiler warnings
Ludovic Rousseau [Sun, 6 Mar 2016 12:42:13 +0000 (13:42 +0100)]
examples: fix 3 compiler warnings

examples/hotplugtest.c:76:28: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        vendor_id  = (argc > 1) ? strtol (argv[1], NULL, 0) : 0x045a;
                   ~              ^~~~~~~~~~~~~~~~~~~~~~~~~
examples/hotplugtest.c:77:28: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        product_id = (argc > 2) ? strtol (argv[2], NULL, 0) : 0x5005;
                   ~              ^~~~~~~~~~~~~~~~~~~~~~~~~
examples/hotplugtest.c:78:28: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        class_id   = (argc > 3) ? strtol (argv[3], NULL, 0) : LIBUSB_HOTPLUG_MATCH_ANY;
                   ~              ^~~~~~~~~~~~~~~~~~~~~~~~~

8 years agodarwin: build hotplugtest sample in Xcode
Ludovic Rousseau [Sun, 6 Mar 2016 12:37:14 +0000 (13:37 +0100)]
darwin: build hotplugtest sample in Xcode

The Xcode project now also builds the hotplugtest (from examples/hotplugtest.c)
target.

8 years agodarwin: fix occasional dead-lock on libusb_exit
parafin [Thu, 15 Oct 2015 17:12:42 +0000 (20:12 +0300)]
darwin: fix occasional dead-lock on libusb_exit

CFRunLoopStop() isn't thread-safe, see for example this bugreport:
https://github.com/joyent/libuv/issues/799
Use CFRunLoopSource instead

Closes #112

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agoxusb: fix typo
Nathan Hjelm [Sat, 5 Mar 2016 15:00:11 +0000 (08:00 -0700)]
xusb: fix typo

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agoReplace obsolete usleep with nanosleep
Stefan Tauner [Mon, 18 Jan 2016 23:02:16 +0000 (00:02 +0100)]
Replace obsolete usleep with nanosleep

This fixes compiling libusb with uclibc.

Closes #141, #165

Signed-off-by: Stefan Tauner <stefan.tauner@gmx.at>
8 years agoREADME.md: add AppVeyor badge
Ludovic Rousseau [Thu, 3 Mar 2016 20:50:15 +0000 (21:50 +0100)]
README.md: add AppVeyor badge

Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
8 years agoAppVeyor: initial configuration file
hacker2490 [Thu, 3 Mar 2016 20:11:20 +0000 (21:11 +0100)]
AppVeyor: initial configuration file

Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
8 years agoWindows: Fix MinGW build
Chris Dickens [Thu, 3 Mar 2016 08:20:33 +0000 (00:20 -0800)]
Windows: Fix MinGW build

The integration of UsbDk moved the windows_error_str() function to
windows_nt_common.c, but the definition of FACILITY_SETUPAPI (which
MinGW headers do not provide) did not follow the move.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agotravis-CI: fails compilation on warning
Ludovic Rousseau [Sat, 27 Feb 2016 16:17:24 +0000 (17:17 +0100)]
travis-CI: fails compilation on warning

The travis-autogen.sh script enable some extra warnings not used by
default. The idea is to detect problem as early as possible.

8 years agoexamples: fix 3 compiler warnings
Ludovic Rousseau [Sat, 27 Feb 2016 16:52:05 +0000 (17:52 +0100)]
examples: fix 3 compiler warnings

fxload.c:202:17: warning: comparison of integers of different signs: 'int' and
      'unsigned long' [-Wsign-compare]
  ...for (j=0; j<ARRAYSIZE(known_device); j++) {
               ~^~~~~~~~~~~~~~~~~~~~~~~~
fxload.c:222:12: warning: comparison of integers of different signs: 'int' and
      'unsigned long' [-Wsign-compare]
                                        if (j < ARRAYSIZE(known_device)) {
                                            ~ ^ ~~~~~~~~~~~~~~~~~~~~~~~
fxload.c:263:13: warning: comparison of integers of different signs: 'int' and
      'unsigned long' [-Wsign-compare]
        for (i=0; i<ARRAYSIZE(path); i++) {
                  ~^~~~~~~~~~~~~~~~

Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
8 years agoexamples: fix 2 compiler warnings
Ludovic Rousseau [Sat, 27 Feb 2016 16:49:55 +0000 (17:49 +0100)]
examples: fix 2 compiler warnings

sam3u_benchmark.c:54:17: warning: comparison of integers of different signs:
      'unsigned int' and 'int' [-Wsign-compare]
                for (i = 0; i < xfr->num_iso_packets; i++) {
                            ~ ^ ~~~~~~~~~~~~~~~~~~~~
sam3u_benchmark.c:67:16: warning: comparison of integers of different signs:
      'unsigned int' and 'int' [-Wsign-compare]
        for (i = 0; i < xfr->actual_length; i++) {
                    ~ ^ ~~~~~~~~~~~~~~~~~~

Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
8 years agoexamples: fix 2 compiler warnings
Ludovic Rousseau [Sat, 27 Feb 2016 16:47:12 +0000 (17:47 +0100)]
examples: fix 2 compiler warnings

ezusb.c:136:13: warning: comparison of integers of different signs: 'int' and
      'size_t' (aka 'unsigned long') [-Wsign-compare]
        if (status != len) {
            ~~~~~~ ^  ~~~
ezusb.c:159:13: warning: comparison of integers of different signs: 'int' and
      'size_t' (aka 'unsigned long') [-Wsign-compare]
        if (status != len) {
            ~~~~~~ ^  ~~~

Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
8 years agodarwin: fix 1 compiler warning
Ludovic Rousseau [Sat, 27 Feb 2016 16:42:55 +0000 (17:42 +0100)]
darwin: fix 1 compiler warning

os/darwin_usb.c:248:18: warning: comparison of integers of different signs:
      'CFIndex' (aka 'long') and 'size_t' (aka 'unsigned long')
      [-Wsign-compare]
      if (length < size) {
          ~~~~~~ ^ ~~~~

Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
8 years agocore: fix 2 compiler warnings
Ludovic Rousseau [Sat, 27 Feb 2016 16:37:49 +0000 (17:37 +0100)]
core: fix 2 compiler warnings

core.c:2361:35: warning: comparison of integers of different signs: 'int' and
      'unsigned long' [-Wsign-compare]
        if (header_len < 0 || header_len >= sizeof(buf)) {
                              ~~~~~~~~~~ ^  ~~~~~~~~~~~
core.c:2370:44: warning: comparison of integers of different signs: 'int' and
      'unsigned long' [-Wsign-compare]
        if (text_len < 0 || text_len + header_len >= sizeof(buf)) {
                            ~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~

Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
8 years agoREADME.md: add Coverity badge
Ludovic Rousseau [Wed, 2 Mar 2016 13:12:04 +0000 (14:12 +0100)]
README.md: add Coverity badge

The libusb project is available on Coverity at https://scan.coverity.com/projects/libusb-libusb

Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
8 years agoWindows: Fix faulty logic that can pick the wrong config descriptor
Chris Dickens [Wed, 2 Mar 2016 08:16:16 +0000 (00:16 -0800)]
Windows: Fix faulty logic that can pick the wrong config descriptor

The WinUSB backend caches the bConfigurationValue of the currently
active configuration when the device is enumerated. In some parts of
the code, the config descriptor is fetched to correlate interfaces
and endpoints by calling libusb_get_config_descriptor() using the
cached bConfigurationValue. This is incorrect usage of the function
as the input parameter is the zero-based configuration index, which
can differ in some devices from the bConfigurationValue.

See discussion: http://marc.info/?l=libusb-devel&m=144355607228333

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows: Add backend support for get_config_descriptor_by_value()
Chris Dickens [Wed, 2 Mar 2016 08:14:50 +0000 (00:14 -0800)]
Windows: Add backend support for get_config_descriptor_by_value()

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows: Fix dev_interface_path memory leak when reusing device ref
Angus Gratton [Tue, 28 Apr 2015 06:49:57 +0000 (16:49 +1000)]
Windows: Fix dev_interface_path memory leak when reusing device ref

windows_get_device_list was leaking dev_interface_path (in either of two
possible places) when a pre-existing device reference was reused.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows: Fix parent USB device reference leak
Angus Gratton [Tue, 28 Apr 2015 06:46:37 +0000 (16:46 +1000)]
Windows: Fix parent USB device reference leak

If windows_get_device_list() found a device that already existed, it
would erronenously increment the parent_dev refcount and cause a
reference leak - the parent device would never be released.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agobootstrap: use autoreconf
Nathan Hjelm [Thu, 25 Feb 2016 20:35:36 +0000 (13:35 -0700)]
bootstrap: use autoreconf

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agotravis: one more fix. need packages under apt
Nathan Hjelm [Fri, 26 Feb 2016 04:51:10 +0000 (21:51 -0700)]
travis: one more fix. need packages under apt

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agotravis: sources line is needed
Nathan Hjelm [Fri, 26 Feb 2016 04:45:15 +0000 (21:45 -0700)]
travis: sources line is needed

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agotravis: bah. remove tabs
Nathan Hjelm [Fri, 26 Feb 2016 04:40:30 +0000 (21:40 -0700)]
travis: bah. remove tabs

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agotravis: use addons to install packages
Nathan Hjelm [Fri, 26 Feb 2016 04:36:26 +0000 (21:36 -0700)]
travis: use addons to install packages

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agoMisc: Link README to README.md to satisfy autotools
Chris Dickens [Thu, 25 Feb 2016 22:13:43 +0000 (14:13 -0800)]
Misc: Link README to README.md to satisfy autotools

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoMisc: Add markdown references for COPYING and PORTING files
Chris Dickens [Thu, 25 Feb 2016 21:53:05 +0000 (13:53 -0800)]
Misc: Add markdown references for COPYING and PORTING files

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoMisc: Convert README to README.md
Chris Dickens [Thu, 25 Feb 2016 21:49:16 +0000 (13:49 -0800)]
Misc: Convert README to README.md

This allows markdown, including displaying Travis build status.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoMerge pull request #154 from hjelmn/darwin_gettime_fix
Nathan Hjelm [Thu, 25 Feb 2016 20:39:46 +0000 (13:39 -0700)]
Merge pull request #154 from hjelmn/darwin_gettime_fix

threads_posix: use backend clock_gettime()

8 years agotravis: test xcode project
Nathan Hjelm [Thu, 25 Feb 2016 20:23:19 +0000 (13:23 -0700)]
travis: test xcode project

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agothreads_posix: use backend clock_gettime()
Nathan Hjelm [Thu, 25 Feb 2016 17:05:49 +0000 (10:05 -0700)]
threads_posix: use backend clock_gettime()

Some platforms do not implement the optional clock_gettime(). Need
to use the backend implementation instead.

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agotravis: Add sudo to apt-get commands
Chris Dickens [Thu, 25 Feb 2016 18:56:16 +0000 (10:56 -0800)]
travis: Add sudo to apt-get commands

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agotravis: Update config file
Chris Dickens [Thu, 25 Feb 2016 18:25:19 +0000 (10:25 -0800)]
travis: Update config file

Use 'script' instead of 'install' to specify build command.
Add linux build option with udev disabled.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agotravis: fix typo
Nathan Hjelm [Thu, 25 Feb 2016 17:25:07 +0000 (10:25 -0700)]
travis: fix typo

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agotravis: ensure udev is installed
Nathan Hjelm [Thu, 25 Feb 2016 17:12:55 +0000 (10:12 -0700)]
travis: ensure udev is installed

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agoAdd Travis CI configuration
Nathan Hjelm [Thu, 25 Feb 2016 16:55:25 +0000 (09:55 -0700)]
Add Travis CI configuration

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
8 years agocore: Remove POSIX threads influence from synchronization code
Chris Dickens [Sat, 30 Jan 2016 10:24:39 +0000 (02:24 -0800)]
core: Remove POSIX threads influence from synchronization code

This commit changes the signatures of the synchronization functions
to reflect the needs of the library rather than the signature of the
pthreads API. The mutex and condition variable attributes parameters
have been removed as no part of the core library makes use of them.

In addition, the condition variable timed-wait function has been modified
to accept the relative time passed in via libusb_wait_for_event(). This
allows the implementation-specific code to handle conversion to absolute
time as necessary, rather than forcing this to occur.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoMisc: Remove unused definitions for usbi_cond_signal()
Chris Dickens [Sat, 30 Jan 2016 10:24:38 +0000 (02:24 -0800)]
Misc: Remove unused definitions for usbi_cond_signal()

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoMisc: Document the return code for control transfers that are too large
Chris Dickens [Wed, 24 Feb 2016 09:50:40 +0000 (01:50 -0800)]
Misc: Document the return code for control transfers that are too large

Closes #110

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoMisc: Add libusb_interrupt_event_handler() to API docs page
Chris Dickens [Wed, 24 Feb 2016 09:21:52 +0000 (01:21 -0800)]
Misc: Add libusb_interrupt_event_handler() to API docs page

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoMisc: Prefix doxygen references in order to namespace libusb
Chris Dickens [Wed, 24 Feb 2016 09:07:20 +0000 (01:07 -0800)]
Misc: Prefix doxygen references in order to namespace libusb

This change add "libusb_" to every group and page definition (and
updates all references accordingly) so that generated man pages
are namespaced for libusb, thus avoiding possible conflict with
other packages.

Closes #131

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoMisc: Make API parameter names consistent and sensible
Chris Dickens [Wed, 24 Feb 2016 08:23:49 +0000 (00:23 -0800)]
Misc: Make API parameter names consistent and sensible

Prior to this commit, API functions taking a libusb_device_handle
argument had the parameter named dev, handle, or dev_handle. This
commit changes the name of all libusb_device_handle parameters to
dev_handle in both the documentation and actual code.

Closes #132

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agosync: Allow transferred argument to be optional in bulk APIs
Chris Dickens [Wed, 24 Feb 2016 07:45:51 +0000 (23:45 -0800)]
sync: Allow transferred argument to be optional in bulk APIs

Closes #139

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agowindows: Fix compilation for MSYS2
Evan Hunter [Fri, 8 Jan 2016 13:53:42 +0000 (13:53 +0000)]
windows: Fix compilation for MSYS2

Closes #140

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agolinux_netlink: Add message authentication and clean up parsing
Chris Dickens [Thu, 28 Jan 2016 22:29:42 +0000 (14:29 -0800)]
linux_netlink: Add message authentication and clean up parsing

This commit adds credentials checking to ensure that we only process
messages received from the kernel. In addition, the parsing logic
was cleaned up and slightly optimized.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agolinux_netlink: Add useful debug messages and clean up error handling
Chris Dickens [Thu, 28 Jan 2016 22:24:09 +0000 (14:24 -0800)]
linux_netlink: Add useful debug messages and clean up error handling

Also addresses some minor whitespace and stylistic issues.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agolinux_netlink: Remove unnecessary header includes and conditionals
Chris Dickens [Thu, 28 Jan 2016 22:15:29 +0000 (14:15 -0800)]
linux_netlink: Remove unnecessary header includes and conditionals

We always require <sys/socket.h> and do not need <linux/filter.h>.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows: Fix style issues in threading code
Chris Dickens [Sat, 30 Jan 2016 08:52:28 +0000 (00:52 -0800)]
Windows: Fix style issues in threading code

Also moves private structure definition outside of header file.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows: Move definitions for Cygwin.
KIMURA Masaru [Thu, 28 Jan 2016 07:25:37 +0000 (16:25 +0900)]
Windows: Move definitions for Cygwin.

Closes #145

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows (winusb): Fix build break introduced in c8f71151 due to typo
Chris Dickens [Thu, 28 Jan 2016 08:43:15 +0000 (00:43 -0800)]
Windows (winusb): Fix build break introduced in c8f71151 due to typo

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoMisc: Minor stylistic improvements to libusbi.h
Chris Dickens [Thu, 28 Jan 2016 08:41:02 +0000 (00:41 -0800)]
Misc: Minor stylistic improvements to libusbi.h

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows/WinCE: Improve the run-time dynamic linking scheme
Chris Dickens [Thu, 28 Jan 2016 08:29:58 +0000 (00:29 -0800)]
Windows/WinCE: Improve the run-time dynamic linking scheme

Prior to this commit, the Windows and WinCE backends had a specific
shortcoming when loading DLLs, that being that once loaded they were
never unloaded. This commit improves this by providing a means to
unload the DLLs during cleanup.

Note that the use of GetModuleHandle() has been removed in favor of
the exclusive use of LoadLibrary(). This was done to ensure that a
reference count is taken against the loaded DLL, which guards against
some other part of the application unloading the DLL that libusb
is currently using.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows: Fix some minor issues in windows_nt_common.c
Chris Dickens [Thu, 28 Jan 2016 08:22:09 +0000 (00:22 -0800)]
Windows: Fix some minor issues in windows_nt_common.c

1) Address a few more stylistic discrepancies
2) Add appropriate type casts for printf functions

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWinCE: Remove unnecessary/unused structure
Chris Dickens [Thu, 28 Jan 2016 08:20:00 +0000 (00:20 -0800)]
WinCE: Remove unnecessary/unused structure

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWinCE: Miscellaneous changes
Chris Dickens [Thu, 28 Jan 2016 08:15:59 +0000 (00:15 -0800)]
WinCE: Miscellaneous changes

1) Make some variables static that are not used outside wince_usb.c
2) Minor stylistic changes to match the rest of the library source

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows: Ensure proper cleanup when backend init() functions fail
Chris Dickens [Wed, 27 Jan 2016 19:46:01 +0000 (11:46 -0800)]
Windows: Ensure proper cleanup when backend init() functions fail

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows: Fix DDK compilation
Pete Batard [Wed, 27 Jan 2016 19:24:13 +0000 (19:24 +0000)]
Windows: Fix DDK compilation

8 years agoWindows: Minor improvements to windows_nt_common.c
Chris Dickens [Wed, 27 Jan 2016 09:25:49 +0000 (01:25 -0800)]
Windows: Minor improvements to windows_nt_common.c

1) Possible memory leak is avoided if htab_create() is called
   while a hash table is already allocated
2) Error handling is simplified in windows_handle_events()

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows: Replace open-coded string alloc + copy with _strdup()
Chris Dickens [Wed, 27 Jan 2016 09:00:55 +0000 (01:00 -0800)]
Windows: Replace open-coded string alloc + copy with _strdup()

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows: Fix compilation warnings when logging is disabled
Chris Dickens [Wed, 27 Jan 2016 08:33:42 +0000 (00:33 -0800)]
Windows: Fix compilation warnings when logging is disabled

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows (usbdk): Remove unnecessary bookkeeping
Chris Dickens [Wed, 27 Jan 2016 08:27:27 +0000 (00:27 -0800)]
Windows (usbdk): Remove unnecessary bookkeeping

The core library will not call the backend's exit() function if the
init() function does not succeed, so keeping track of whether init()
successfully completed is redundant.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows (usbdk): Remove unnecessary/unused structure
Chris Dickens [Wed, 27 Jan 2016 08:25:25 +0000 (00:25 -0800)]
Windows (usbdk): Remove unnecessary/unused structure

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoMisc: Fix up Visual Studio project files
Chris Dickens [Wed, 27 Jan 2016 08:15:11 +0000 (00:15 -0800)]
Misc: Fix up Visual Studio project files

This commit sorts the source and header files by name (for easier
human parsing), adds windows_nt_common.c to the 2010 and 2012
projects, and removes some CPP defines that should not be present
in the libusb_static_2015.vcxproj file.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows: Source file cleanup
Chris Dickens [Wed, 27 Jan 2016 07:40:33 +0000 (23:40 -0800)]
Windows: Source file cleanup

This commit addresses a few different issues:

1) Whitespace made consistent with the rest of the library source
2) Formatting of function and variable declarations made consistent
   with the rest of the library source
3) Functions and variables made static where possible
4) Definitions in header files moved if not used publicly

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoMisc: Minor makefile cleanup
Chris Dickens [Sun, 24 Jan 2016 07:08:09 +0000 (23:08 -0800)]
Misc: Minor makefile cleanup

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agobuild: Integrate usbdk backend
Dmitry Fleytman [Wed, 20 Jan 2016 15:05:55 +0000 (17:05 +0200)]
build: Integrate usbdk backend

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agousbdk: Introduce usbdk backend
Dmitry Fleytman [Wed, 20 Jan 2016 15:05:54 +0000 (17:05 +0200)]
usbdk: Introduce usbdk backend

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agowindows: Rename windows_usb.h/c windows_winusb.h/c
Dmitry Fleytman [Wed, 20 Jan 2016 15:05:53 +0000 (17:05 +0200)]
windows: Rename windows_usb.h/c windows_winusb.h/c

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agowindows: Move common definitions to a separate file
Dmitry Fleytman [Wed, 20 Jan 2016 15:05:52 +0000 (17:05 +0200)]
windows: Move common definitions to a separate file

New files windows_nt_common.h/c introduced.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agolinux: Correctly return device configuration when using usbfs
Chris Dickens [Wed, 6 Jan 2016 17:57:15 +0000 (09:57 -0800)]
linux: Correctly return device configuration when using usbfs

libusb_get_configuration() has been broken when using a Linux kernel
that requires the use of usbfs to obtain the current configuration
value. This commit resolves this issue and also modifies the
usbfs_get_active_config() function to update the cached active
configuration value itself instead of requiring the callers to do it.

Closes #137

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWinCE: Fix printf format specifiers
Chris Dickens [Thu, 7 Jan 2016 06:17:22 +0000 (22:17 -0800)]
WinCE: Fix printf format specifiers

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows: Fix printf format specifiers in poll_windows.c
Chris Dickens [Thu, 7 Jan 2016 06:16:58 +0000 (22:16 -0800)]
Windows: Fix printf format specifiers in poll_windows.c

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows: Fix compiler warnings due to type mismatches
Chris Dickens [Thu, 7 Jan 2016 06:16:26 +0000 (22:16 -0800)]
Windows: Fix compiler warnings due to type mismatches

There are some differences in how the DWORD type is defined between
native Windwos compilers and Cygwin where the former always uses long
and the latter uses long or int depending on the architecture. Since
the DWORD type is always 4 bytes, all uses of DWORD in printf are
cast to unsigned int, which consistently 4 bytes across all platforms.
Other mismatching printf format specifiers were also changed appropriately.

Additionally, a type cast is added for _beginthreadex on Cygwin.

Closes #106

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows: Use strcasecmp() instead of stricmp() on Cygwin
Chris Dickens [Thu, 7 Jan 2016 05:52:36 +0000 (21:52 -0800)]
Windows: Use strcasecmp() instead of stricmp() on Cygwin

Cygwin does not define the latter in all versions, so this commit
uses the former POSIX function that Cygwin does provide.

Closes #104

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoExamples: fix typo in Nathan Hjelm email
Ludovic Rousseau [Wed, 6 Jan 2016 09:20:24 +0000 (10:20 +0100)]
Examples: fix typo in Nathan Hjelm email

8 years agoWindows: Add Visual Studio 2015 support
Brent Rector [Sat, 25 Jul 2015 08:36:56 +0000 (01:36 -0700)]
Windows: Add Visual Studio 2015 support

Modified from original to remove two unnecessary files and address
type-casting discrepancies across platforms.

Closes #60
Closes #83
Closes #120

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoWindows: Patch to support VirtualHub
johannrichard [Tue, 22 Dec 2015 16:01:54 +0000 (17:01 +0100)]
Windows: Patch to support VirtualHub

Integrate VirtualHub (VHHUB) in LibUSB, as per
http://libusb.6.n5.nabble.com/libusb-Patch-to-support-VirtualHere-td5714167.html

Closes #133

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoMisc: Spelling fixes
Tobias Klauser [Fri, 25 Sep 2015 11:50:35 +0000 (13:50 +0200)]
Misc: Spelling fixes

Fix spelling errors found by codespell, some of them in API
documentation and user visible messages.

Closes #102

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
8 years agoMisc: Simplify Haiku build and fix broken parallel build
Chris Dickens [Thu, 3 Dec 2015 20:59:20 +0000 (12:59 -0800)]
Misc: Simplify Haiku build and fix broken parallel build

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>
8 years agoAPI: Add libusb_interrupt_event_handler() function
Chris Dickens [Thu, 10 Dec 2015 08:20:18 +0000 (00:20 -0800)]
API: Add libusb_interrupt_event_handler() function

This new function will allow the user to purposely interrupt an
event handling thread, causing it to return from the event handling
function. This is mainly useful for cleanly exiting from a dedicated
event handling thread during application shutdown.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>