platform/upstream/libusb.git
11 years agoCore: Make libusb_error_name also handle transfer status codes
Hans de Goede [Sat, 15 Sep 2012 10:31:00 +0000 (11:31 +0100)]
Core: Make libusb_error_name also handle transfer status codes

Note that for the code 0 which means success resp. completed we have an
overlap in the codes. This is not a problem since normally one would not
call libusb_error_name on success / normal completion.

11 years agoSamples: Fix compiler warnings in fxload
Ludovic Rousseau [Sat, 15 Sep 2012 08:18:50 +0000 (10:18 +0200)]
Samples: Fix compiler warnings in fxload

ezusb.c: In function  "ezusb_cpucs"
ezusb.c:163: warning: initialization discards qualifiers from pointer target type
ezusb.c: At top level:
ezusb.c:193: warning: no previous prototype for "parse_ihex"
ezusb.c:340: warning: no previous prototype for "parse_bin"
ezusb.c:377: warning: no previous prototype for "parse_iic"
ezusb.c: In function "ram_poke":
ezusb.c:451: warning: enumeration value "_undef" not handled in switch
ezusb.c:491: warning: passing argument 2 of "ezusb_write" discards qualifiers from pointer target type

11 years agoCore: Update libusb.h header in accordance with the latest USB specs
Pete Batard [Wed, 5 Sep 2012 23:47:08 +0000 (00:47 +0100)]
Core: Update libusb.h header in accordance with the latest USB specs

* IMPORTANT: This update fixes a typo in the API where MaxPower was being
  used instead of bMaxPower, with the latter being what is actually in
  the specs.
* As a result, applications that were using MaxPower need to be updated
  for bMaxPower.
* If you must maintain compatibility with libusb or older versions of
  libusbx, you may also want to either use a #define or copy/paste
  struct libusb_config_descriptor from libusb.h under a new name, and
  then use a cast on calls that require it. For more info, see the
  1.0.13 release notes in the NEWS file.
* Also update copyright notice

11 years agoSamples: Display VID:PID of the tested device in xusb
Ludovic Rousseau [Thu, 13 Sep 2012 13:50:43 +0000 (15:50 +0200)]
Samples: Display VID:PID of the tested device in xusb

* Also amend the wording of the "no option" comment.
* Closes #42

11 years agoWindows: Switch to ALLOW_PARTIAL_READS pipe policy enabled by default
Pete Batard [Thu, 13 Sep 2012 23:10:57 +0000 (00:10 +0100)]
Windows: Switch to ALLOW_PARTIAL_READS pipe policy enabled by default

* This avoids an issue when libusbK is used for bulk transfers, which
  is most likely due to a libusbK bug
* See https://sourceforge.net/mailarchive/message.php?msg_id=29736015

11 years agoSamples: Add fxload sample for Cypress EZ-USB chips
Pete Batard [Tue, 11 Sep 2012 00:01:07 +0000 (01:01 +0100)]
Samples: Add fxload sample for Cypress EZ-USB chips

* This program was modified from the original fxload at:
  http://linux-hotplug.sourceforge.net to add libusbx
  as well as non HEX images support.
* Only supports RAM upload for now, with EEPROM and FX3
  support to be added at a later stage.

11 years agoAll: Avoid polluting errors reported on device disconnect
Hans de Goede [Wed, 12 Sep 2012 01:03:47 +0000 (02:03 +0100)]
All: Avoid polluting errors reported on device disconnect

* Makes libusb_cancel_transfer not log an error when the cancel fails
  with LIBUSB_ERROR_NO_DEVICE, so that apps can properly clean things
  up on device disconnect without flooding the console with these errors.
* Also, some devices (Cypress FX) may switch VID:PID on the fly during
  firmware upload => reduce severity of the Windows message when that happens.

11 years agoDoc: Update logging documentation regarding stderr usage
Pete Batard [Mon, 10 Sep 2012 23:17:39 +0000 (00:17 +0100)]
Doc: Update logging documentation regarding stderr usage

11 years agoWindows: Fix handling of composite devices
Pete Batard [Wed, 5 Sep 2012 21:51:19 +0000 (22:51 +0100)]
Windows: Fix handling of composite devices

* Pass missing sub_api parameter to set_composite_interface() and
  composite_submit_control_transfer()
* Remove api_flags attribute, that cannot apply for multiple interfaces
* Also simplifies the internal ENUM_DEBUG mode
* Also move polluting info logging message to debug

11 years agoSamples: xusb improvements
Pete Batard [Mon, 3 Sep 2012 19:43:18 +0000 (20:43 +0100)]
Samples: xusb improvements

* update and fix usage details
* make topology and speed printout optional (option -i)
* remove unneeded option -g

11 years agoWindows: Suppress unwanted error message on filter driver
Pete Batard [Sun, 26 Aug 2012 23:16:00 +0000 (00:16 +0100)]
Windows: Suppress unwanted error message on filter driver

* Interface access error message was unconditional, even if the
  filter driver was found later on.

11 years agoLinux: Return ERROR_NOT_FOUND in detach-kernel-driver if usbfs is already bound
Hans de Goede [Wed, 22 Aug 2012 10:47:00 +0000 (11:47 +0100)]
Linux: Return ERROR_NOT_FOUND in detach-kernel-driver if usbfs is already bound

* Currently applications for devices which only are accessed from userspace
  can use claim / release interface to make sure they don't get in each others
  way.
* The same however does not work for applications which first need to detach
  a "native" / in kernel driver, as this detach will not only detach native
  drivers but also the usbfs driver, thus stealing the device from another
  userspace / libusbx app.
* This patch fixes libusb_detach_kernel_driver to only detach "real" kernel
  drivers and not the special usbfs driver used for userspace access to
  USB devices. If the usbfs driver is found LIBUSB_ERROR_NOT_FOUND will be
  returned to indicate no driver was detached.

11 years agoLinux: Avoid unnecessary splitting of bulk transfers
Hans de Goede [Wed, 22 Aug 2012 10:47:00 +0000 (11:47 +0100)]
Linux: Avoid unnecessary splitting of bulk transfers

* With the latest kernels it is no longer needed to always split large bulk
  transfers into multiple urbs. This patch takes advantage of this by not
  splitting when not necessary. Note that the non-split code path is in essence
  using the old split code path with an urb count which is always 1.
* This leads to more sane handling of large transfers with recent kernels,
  although our splitting code is well tested, not splitting at all still is
  a lot better :)
* When used with a recent kernel, this also fixes the problems, on XHCI attached
  devices, when a large bulk-in transfer ends with a short read in an urb other
  then the last urb.
* For more on this see: http://marc.info/?l=linux-usb&m=133797554910355

11 years agoLinux: Add support for the new get_capabilities ioctl
Hans de Goede [Wed, 22 Aug 2012 10:47:00 +0000 (11:47 +0100)]
Linux: Add support for the new get_capabilities ioctl

* There were a few (new) usbdevfs capabilities which libusbx could not
  discover in any other way then checking the kernel version.
* However, this presents the following problems:
  1) It is just not very pretty
  2) Given the tendency of enterprise distros to backport stuff it is not
     reliable
  3) Some of these features turn out to not work with certain host controllers,
     making depending on them based on the kernel version not a good idea
* Therefore a new USBDEVFS_GET_CAPABILITIES ioctl has been added to the kernel
  to offer a better way to find out a device's capabilities (technically
  the capabilities of the host controller to which the device is attached,
  but that does not matter).

11 years agoCore: Handle >= 1 second transfer timeout in libusb_submit_transfer()
Peter Stuge [Wed, 22 Aug 2012 08:32:10 +0000 (01:32 -0700)]
Core: Handle >= 1 second transfer timeout in libusb_submit_transfer()

* Comparisons between tv_nsec and 1 sec should be >= rather than >,
  as we can end up in situations where tv_nsec is exactly 1000000000,
  which calls such as timerfd_create() do not accept.
* Issue reported by Sebastian K. See:
  https://sourceforge.net/mailarchive/message.php?msg_id=29706972

11 years agoMisc: Update and shorten various libusbx URLs
Pete Batard [Wed, 22 Aug 2012 20:42:21 +0000 (21:42 +0100)]
Misc: Update and shorten various libusbx URLs

11 years agoWindows: Add support for 2nd gen Renesas USB 3.0 controllers
Nicholas Corgan [Mon, 20 Aug 2012 20:32:24 +0000 (13:32 -0700)]
Windows: Add support for 2nd gen Renesas USB 3.0 controllers

* Driver version 3.0.20.0 for uPD720201 & uPD720202 uses RUSB3HUB
* Closes #40

11 years agoWindows: Add libusbk.sys & libusb0.sys driver support
Pete Batard [Sun, 19 Aug 2012 22:40:42 +0000 (23:40 +0100)]
Windows: Add libusbk.sys & libusb0.sys driver support

* Both libusbk and libusb0.sys rely on libusbk.dll being
  installed to provides a WinUSB-like API for driver access.
* In case libusbk.dll is not present, fall back to WinUSB.
* Closes #11
* Closes #12

11 years agoWindows: Fix C4005 warning under VS2012 for inline.
Anthony Clay, ZarthCode LLC [Sun, 19 Aug 2012 19:19:40 +0000 (14:19 -0500)]
Windows: Fix C4005 warning under VS2012 for inline.

* Changed inline macro to not fire when using Visual Studio/C++,
  which attempts to redefine the macro - resulting in a C4005 warning.

11 years agoSamples: Make target mandatory with -b option in xusb
Pete Batard [Sun, 12 Aug 2012 21:57:10 +0000 (22:57 +0100)]
Samples: Make target mandatory with -b option in xusb

11 years agoCore: Improve instrumentation of timerfd_settime failures
Pete Batard [Sun, 12 Aug 2012 21:37:02 +0000 (22:37 +0100)]
Core: Improve instrumentation of timerfd_settime failures

* Report errno as well as itimerspec data
* Also reuse the timeout variable set to &transfer->timeout

11 years agoCore: Fix a Clang warning in io.c
Pete Batard [Tue, 7 Aug 2012 12:36:16 +0000 (13:36 +0100)]
Core: Fix a Clang warning in io.c

* Using sizeof() in the UNUSED() macro didn't silence all
  unused variable warnings.
* Also fix an "unused ctx" warning when ENABLE_DEBUG_LOGGING is on
* Also improve debug output on libusb_open() failure

11 years agoWindows: Add workaround for Intel USB 3.0 root hubs
Matthias Bolte [Sat, 28 Jul 2012 19:24:31 +0000 (21:24 +0200)]
Windows: Add workaround for Intel USB 3.0 root hubs

* Intel USB 3.0 root hubs are similar to the Nec/Renesas USB 3.0 root
  hubs as they aren't listed under "USB" either but under "IUSB3".
* Extend the existing workaround for Nec/Renesas USB 3.0 root hubs to
  handle the Intel ones as well.
* Closes #39

11 years agoCore: Fix unconditional disarming of timerfd
Pete Batard [Tue, 10 Jul 2012 00:59:45 +0000 (01:59 +0100)]
Core: Fix unconditional disarming of timerfd

* Existing code appears disarms the timerfd always, which cancels
  pending timeouts as soon as one packet completes.
* This fix moves the disarming of the timerfd to
  arm_timerfd_for_next_timeout(), where it is now done conditionally.
  It also avoids calling disarm outside of the above call.
* This patch also ensures that all handling of the timerfd is done
  under the flying transfers lock.
* Issue reported by Hans de Goede. For more info, see:
  https://sourceforge.net/mailarchive/message.php?msg_id=29442693

11 years agoCore: NULL list pointers on deletion
Orin Eman [Fri, 3 Aug 2012 13:21:45 +0000 (14:21 +0100)]
Core: NULL list pointers on deletion

* This aims at highlighting unwanted behaviours on list operations,
  and facilitate early detection of potential bugs.
* This also requires a fix in threads_windows.c
* See http://sourceforge.net/mailarchive/message.php?msg_id=29626351

11 years agoMisc: Add a readme for git user
Pete Batard [Wed, 1 Aug 2012 16:43:33 +0000 (17:43 +0100)]
Misc: Add a readme for git user

* Suggested by Yves Arrouye:
  http://sourceforge.net/mailarchive/message.php?msg_id=29577839

11 years agoWindows: Set device number for root hubs to 1
Pete Batard [Wed, 18 Jul 2012 17:25:11 +0000 (18:25 +0100)]
Windows: Set device number for root hubs to 1

* Other platforms (Linux, OS-X) appear to use 1 => follow suit.
* For non root hub devices, we simply increment the USB device address.
* Collisions with device address 0 are not expected, but we add
  an assertion for just in case.

11 years agoWindows: Fix overflow when handling HID or composite devices
Pete Batard [Tue, 17 Jul 2012 16:36:13 +0000 (17:36 +0100)]
Windows: Fix overflow when handling HID or composite devices

* When libusb_get_device_list() is called mutliple times, the HID device
  path was unconditionally duplicated in the list of device's interfaces.
* Because array boundaries were not checked, this caused overflow and crash.
* This patch adds an out of bound check and also ensures that duplication
  of data, for HID and composite, does not occur
* It also renames the private composite_api_flags to api_flags, as well as
  reorganizes the private attributes
* Bug report and part of the fix provided by Toby Gray

11 years agoWindows: usbi_cond_destroy() should free handles created by usbi_cond_intwait().
Simon Haggett [Tue, 10 Jul 2012 15:07:45 +0000 (16:07 +0100)]
Windows: usbi_cond_destroy() should free handles created by usbi_cond_intwait().

* Without this change every call to usbi_cond_destroy() leaks an event handle.

11 years agoAll: Replace malloc+memset with calloc
Davidlohr Bueso [Wed, 11 Jul 2012 12:53:00 +0000 (13:53 +0100)]
All: Replace malloc+memset with calloc

11 years agoCore: Prefix LOG_LEVEL_ with LIBUSB_ to avoid conflicts
Pete Batard [Mon, 2 Jul 2012 22:39:19 +0000 (23:39 +0100)]
Core: Prefix LOG_LEVEL_ with LIBUSB_ to avoid conflicts

* The LOG_LEVEL_ enums, that were moved to the public API
  in 933a319469bcccc962031c989e39d9d1f44f2885 may conflict
  with applications/headers that also define their own
  LOG_LEVEL_ values internally.
* As a matter of fact, as per Trac #31, this produces a
  conflict with libusb-compat, as it defines its own levels.

11 years agoMisc: Fix more Clang warnings in core and darwin
Pete Batard [Thu, 28 Jun 2012 21:49:47 +0000 (22:49 +0100)]
Misc: Fix more Clang warnings in core and darwin

* http://sourceforge.net/mailarchive/message.php?msg_id=29418038
* core.c:700:4: warning: Function call argument is an uninitialized value
* darwin_usb.c:1713:11: warning: Access to field 'cfSource' results in a
  dereference of a null pointer (loaded from variable 'hpriv')
* sync.c/dpfp.c/dpfp_threaded.c: warning: Result of 'malloc' is converted
  to a pointer of type 'unsigned char', which is incompatible with sizeof
  operand type

11 years agoWindows: Address MSVC Level 4 & WDK's OACR/Prefast warnings
Pete Batard [Mon, 25 Jun 2012 18:13:42 +0000 (19:13 +0100)]
Windows: Address MSVC Level 4 & WDK's OACR/Prefast warnings

* The library is now compiled with warning level 4 for VS2010
* Move silencing of 4200, 28125 and 28719 to msvc/config.h
* Add fixes in core to silence unused variables warnings
* Ensure that spinlock is always set interlocked in poll_windows
* Add missing check for calloc return value
* Fix data assignation in conditionals warnings
* Fix an OACR/Prefast error related to the use of strncpy in xusb.c
* Also fixes whitespace inconsistencies in core
* Issues reported by Orin Eman and Xiaofan Chen. See:
  https://sourceforge.net/mailarchive/message.php?msg_id=29412656

12 years agoWindows: Some versions of dlltool require a library name
Xiaofan Chen [Sun, 17 Jun 2012 12:46:40 +0000 (20:46 +0800)]
Windows: Some versions of dlltool require a library name

* Even though the library name is optional as specified by Microsoft,
  some recent versions of libtool require one in libusb-1.0.def.
* Reference thread in MinGW-w64 mailing list.
  http://comments.gmane.org/gmane.comp.gnu.mingw.w64.general/5141

12 years agoWindows: Fix warnings reported by the Intel Compiler
Pete Batard [Thu, 21 Jun 2012 19:17:09 +0000 (20:17 +0100)]
Windows: Fix warnings reported by the Intel Compiler

* windows_usb.c(161): warning #181: argument is incompatible
  with corresponding format string conversion
* windows_usb.c(2124): warning #111: statement is unreachable
  usbi_dbg("ERROR: broken timer thread");
* multiple: warning #188: enumerated type mixed with another
* Issues reported by Orin Eman

12 years agolibusbx-1.0.12
Pete Batard [Fri, 15 Jun 2012 14:14:48 +0000 (15:14 +0100)]
libusbx-1.0.12

12 years agoSamples: Remove USB version for speed designations in xusb
Xiaofan Chen [Thu, 14 Jun 2012 11:42:02 +0000 (12:42 +0100)]
Samples: Remove USB version for speed designations in xusb

12 years agoWindows: Fix erroneous pointer array allocation reported by Clang
Pete Batard [Wed, 13 Jun 2012 12:38:46 +0000 (13:38 +0100)]
Windows: Fix erroneous pointer array allocation reported by Clang

* Result of 'calloc' is converted to a pointer of type 'unsigned char *',
  which is incompatible with sizeof operand type 'PUSB_CONFIGURATION_DESCRIPTOR'
* priv->config_descriptor is indeed an array of pointers, with each descriptor
  allocated, rather than a sequential list of fixed descriptor.

12 years agoCore: Fix Clang warnings
Pete Batard [Wed, 13 Jun 2012 12:33:00 +0000 (13:33 +0100)]
Core: Fix Clang warnings

core.c:
* Result of 'malloc' is converted to a pointer of type 'struct libusb_device *',
  which is incompatible with sizeof operand type 'void *'
* Memory is never released; potential leak of memory pointed to by 'devs'
* Assigned value is garbage or undefined (due to potentially empty and
  uninitialized device list)
descriptor.c:
* Function call argument is an uninitialized value
io.c:
* Call to 'malloc' has an allocation size of 0 bytes
* Branch condition evaluates to a garbage value (due to get_next_timeout
  returning a negative error code instead of zero on error)

12 years agolibusbx 1.0.12-rc1
Pete Batard [Mon, 11 Jun 2012 13:03:57 +0000 (14:03 +0100)]
libusbx 1.0.12-rc1

12 years agoAutotools: add libusb-1.0.def and libusb_nano.h as dependencies
Pete Batard [Mon, 11 Jun 2012 13:12:56 +0000 (14:12 +0100)]
Autotools: add libusb-1.0.def and libusb_nano.h as dependencies

* Also add version_nano.h to EXTRA_DIST as it is not added to the
  dist archive by default

12 years agoWindows: Enable MinGW and MSVC DLL interchangeability
Pete Batard [Fri, 8 Jun 2012 22:31:56 +0000 (23:31 +0100)]
Windows: Enable MinGW and MSVC DLL interchangeability

* Because we use the WINAPI calling convention, the def file MUST have the @n
  aliases. There is no way around this as MinGW's .o use decoration always
  for __stdcall, which can't be turned off.
* dlltool must therefore be invoked to create a proper import lib from the .def,
  using the --kill-at option.
* To do that, a CREATE_IMPORT_LIB autotools variable is introduced.
* Note: the .def file is currently maintained manually.

12 years agoAll: Prevent memory leaks on realloc failures
Pete Batard [Thu, 7 Jun 2012 18:27:43 +0000 (19:27 +0100)]
All: Prevent memory leaks on realloc failures

* p = realloc(p, new_size) does not free the original buffer in case of
  a realloc failure.
* reallocf() can be used to do so, but is not available on all platforms.
* This patch introduces usbi_reallocf() in libusbi.h and use that instead of realloc
* Issue and original patch submitted by Moritz Lipp (trac #27)

12 years agoWindows: Fix possible crash when using longjmp and gcc 4.6
Pete Batard [Thu, 7 Jun 2012 10:55:30 +0000 (11:55 +0100)]
Windows: Fix possible crash when using longjmp and gcc 4.6

* With gcc-4.6 the option -fomit-frame-pointer is turned on per default
  even for the win32 target. This results in segfaults for any application
  using setjmp/longjmp and MSVCRT.dll on WinXP.
  See http://gcc.gnu.org/ml/gcc/2011-10/msg00351.html
* Issue reported by Lars Kanis

12 years agoCore: Display libusbx version in libusb_init's debug output
Pete Batard [Wed, 6 Jun 2012 12:49:41 +0000 (13:49 +0100)]
Core: Display libusbx version in libusb_init's debug output

12 years agoAutotools: Fix autogen.sh behavior when libtool is not found
Lars Wirzenius [Wed, 6 Jun 2012 16:34:04 +0000 (17:34 +0100)]
Autotools: Fix autogen.sh behavior when libtool is not found

* Fix naked "exit", which no exit code, to prevent a build failure
  from being noticed automatically if a build dependency is lacking.
* Also printed error message to stderr rather than stdout.

12 years agoLinux: Fix a major regression in threads_posix.c
Pete Batard [Wed, 6 Jun 2012 09:53:43 +0000 (10:53 +0100)]
Linux: Fix a major regression in threads_posix.c

* On some Linux platforms, libusbx compilation breaks with:
  error: implicit declaration of function ‘pthread_mutexattr_settype’
* This regression, introduced in 463dda06db5da5de0eab32820c7af60605625afe,
  is due to pthread.h needing __USE_UNIX98, which is tied to _XOPEN_SOURCE
  or _GNU_SOURCE being correctly defined, and which the inclusion of
  <unistd.h> before the _XOPEN_SOURCE override modified
* As _GNU_LINUX ensures the definition of __USE_UNIX98 and we require it
  for syscalls, we now only define _GNU_SOURCE for Linux.

12 years agoAutotools: Fix versioning regression in configure.ac
Pete Batard [Tue, 5 Jun 2012 16:29:46 +0000 (17:29 +0100)]
Autotools: Fix versioning regression in configure.ac

* Because of missing [], "LIBUSB_MICROLIBUSB_RC" was being displayed
  in lieu of version number
* Regression introduced with c9d41fe5f0324d969f758f42843e1fd05859f438

12 years agoCore: Add toggleable debug logging
Pete Batard [Thu, 31 May 2012 17:31:34 +0000 (18:31 +0100)]
Core: Add toggleable debug logging

* Also fix a missing space in debug log messages introduced
  with the previous timestamp logging update

12 years agoCore: Fix "LOG_LEVEL_NONE not handled in switch" warning
Ludovic Rousseau [Fri, 1 Jun 2012 09:52:17 +0000 (11:52 +0200)]
Core: Fix "LOG_LEVEL_NONE not handled in switch" warning

12 years agoSamples: Fix no previous prototype warnings in xusb
Ludovic Rousseau [Fri, 1 Jun 2012 09:40:31 +0000 (11:40 +0200)]
Samples: Fix no previous prototype warnings in xusb

12 years agoAutotools: Apply autoupdate 2.68 recommendations
Ludovic Rousseau [Fri, 1 Jun 2012 09:30:00 +0000 (11:30 +0200)]
Autotools: Apply autoupdate 2.68 recommendations

* Not applied: AC_PREREQ([2.68]) as this doesn't seem
  necessary and 2.68 was released less than 2 years ago.

12 years agoCore: Send all logging output to stderr
Pete Batard [Mon, 28 May 2012 11:33:18 +0000 (12:33 +0100)]
Core: Send all logging output to stderr

* This effectively removes the use of stdout for info messages

12 years agoDarwin: More OS-X logging improvements
Pete Batard [Thu, 31 May 2012 12:11:15 +0000 (13:11 +0100)]
Darwin: More OS-X logging improvements

* Further alignment of log messages according to severity
* Fix "'darwin_error_str' defined but not used" warning when
  option --disable-log is used (reported by Xiaofan Chen)

12 years agoWindows: Add new API calls to DLL .def file
Pete Batard [Tue, 29 May 2012 15:06:57 +0000 (16:06 +0100)]
Windows: Add new API calls to DLL .def file

* Generated from a MinGW32 generated DLL using the command:
  echo -e "LIBRARY\nEXPORTS" > libusb-1.0.def; strings libusb-1.0.dll | grep libusb | grep @ | sort | sed -e "s/\(.*\)@\([0-9]*\)/  \1\n  \1@\2 = \1/" >> libusb-1.0.def

12 years agoWindows: Restore HID support
Pete Batard [Fri, 11 May 2012 22:34:03 +0000 (23:34 +0100)]
Windows: Restore HID support

12 years agoCore: Only display timestamps in debug mode and use init() as origin
Pete Batard [Thu, 24 May 2012 15:18:58 +0000 (16:18 +0100)]
Core: Only display timestamps in debug mode and use init() as origin

12 years agoCore: Define log levels in libusb.h
Pete Batard [Thu, 24 May 2012 12:36:23 +0000 (13:36 +0100)]
Core: Define log levels in libusb.h

* Also update xusb sample to use these levels

12 years agoDarwin: Align severity of OS-X logging messages
Pete Batard [Thu, 24 May 2012 10:42:47 +0000 (11:42 +0100)]
Darwin: Align severity of OS-X logging messages

* Some informational messages were actually debug or warning
* Fixes #1

12 years agoAll: Add parent and port topology calls
Pete Batard [Thu, 10 May 2012 19:01:10 +0000 (20:01 +0100)]
All: Add parent and port topology calls

* Adds libusb_get_port_number, libusb_get_parent and libusb_get_port_path
* Linux implementation provided by Alan Stern, OS X by Nathan Hjelm
* Unsupported for *BSD platforms

12 years agoMisc: Ensure all sources are UTF-8
Pete Batard [Wed, 23 May 2012 17:25:01 +0000 (18:25 +0100)]
Misc: Ensure all sources are UTF-8

* Also remove extra lines at the end of samples

12 years agoWindows: Reduce severity of initial conf desc readout failures
Pete Batard [Tue, 22 May 2012 23:10:19 +0000 (00:10 +0100)]
Windows: Reduce severity of initial conf desc readout failures

* Failure to read the config descriptor through regular API calls can
  occur for some hubs (eg. 05E3:0608) and is of no major consequence.
* Later failures still reported with error severity as they may hide
  something more dramatic
* Issue reported by Jerry from NovaDSP

12 years agoWindows: Fix missing cygwin thread ID
Pete Batard [Thu, 10 May 2012 16:42:16 +0000 (17:42 +0100)]
Windows: Fix missing cygwin thread ID

* Cygwin uses POSIX threads, not Windows threads

12 years agoWindows: Add INSTALL_WIN.txt
Pete Batard [Thu, 10 May 2012 15:44:30 +0000 (16:44 +0100)]
Windows: Add INSTALL_WIN.txt

12 years agoMisc: Separate nano from version.h
Pete Batard [Thu, 10 May 2012 14:56:51 +0000 (15:56 +0100)]
Misc: Separate nano from version.h

* As version.h processed by autotools, the automatic updating of the
  nano there can result in unneeded reconfs (eg. after issuing a git
  pull, regardless of whether the conf is still valid)
* Avoid this by placing the nano in its own file, as it won't be
  processed by autoconf. This also simplifies the versioning git hooks
  and removes the sed dependency.

12 years agoSamples: Use the implicit _SOURCES rule
Ludovic Rousseau [Wed, 9 May 2012 07:13:41 +0000 (09:13 +0200)]
Samples: Use the implicit _SOURCES rule

* By default automake looks for a source file foo.c for a foo binary.

12 years agoSamples: Use a common LDADD for all examples
Ludovic Rousseau [Wed, 9 May 2012 07:12:01 +0000 (09:12 +0200)]
Samples: Use a common LDADD for all examples

* Similar to libusb patch a129732fb45fc424743f26f01c906e4514f11521

12 years agoSamples: prefer __linux__ over __linux define in xusb
Pete Batard [Thu, 10 May 2012 14:35:07 +0000 (15:35 +0100)]
Samples: prefer __linux__ over __linux define in xusb

* While both should work, __linux__ seems to be preferred and
  what we use in threads_posix.c
* Also fix a typo in .private/README.txt

12 years agolibusbx-1.0.11
Pete Batard [Tue, 8 May 2012 22:04:44 +0000 (23:04 +0100)]
libusbx-1.0.11

12 years agoDarwin: Sync type of num_iso_packets fields
Ludovic Rousseau [Tue, 8 May 2012 18:34:12 +0000 (20:34 +0200)]
Darwin: Sync type of num_iso_packets fields

* num_iso_packets was a "size_t" in "struct darwin_transfer_priv" and an
  "int" in "struct libusb_transfer".  The field is now an int in the two
  structures
* Fixes warning
  os/darwin_usb.c: In function ‘submit_iso_transfer’:
  os/darwin_usb.c:1334: warning: comparison between signed and unsigned

12 years agoCore: Handle TRANSFER_ERROR/TRANSFER_CANCELLED for sync transfers
Ludovic Rousseau [Tue, 8 May 2012 13:53:56 +0000 (15:53 +0200)]
Core: Handle TRANSFER_ERROR/TRANSFER_CANCELLED for sync transfers

* Return the more appropriate LIBUSB_ERROR_IO instead of
  LIBUSB_ERROR_OTHER for the cases LIBUSB_TRANSFER_ERROR and
  LIBUSB_TRANSFER_CANCELLED
* Fixes warnings similar to the following when using the GCC
  option -Wswitch-enum:
  warning: enumeration value ‘LIBUSB_TRANSFER_ERROR’ not handled in switch

12 years agoBSD: Add thread ID support for OpenBSD > 5.1
Pete Batard [Tue, 8 May 2012 11:10:59 +0000 (12:10 +0100)]
BSD: Add thread ID support for OpenBSD > 5.1

* Uses syscall(SYS_getthrid) which requires real thread support,
  currently only available in 5.1-current (but not 5.1-release).
  For OpenBSD <= 5.1, -1 will be returned for the thread ID.

12 years agoSamples: fix strcat vs strlcat warning on OpenBSD
Pete Batard [Mon, 7 May 2012 14:41:50 +0000 (15:41 +0100)]
Samples: fix strcat vs strlcat warning on OpenBSD

* Without this, OpenBSD produces the following warning:
  strcat() is almost always misused, please use strlcat()

12 years agolibusbx 1.0.11-rc1
Pete Batard [Sun, 6 May 2012 23:05:36 +0000 (00:05 +0100)]
libusbx 1.0.11-rc1

12 years agoCore: Add a timestamping and thread ID to logging
Peter Stuge [Sun, 6 May 2012 17:04:00 +0000 (17:04 +0000)]
Core: Add a timestamping and thread ID to logging

12 years agoAutotools: Use "$@" instead of $* to avoid spaces problems
Ludovic Rousseau [Fri, 4 May 2012 15:56:00 +0000 (16:56 +0100)]
Autotools: Use "$@" instead of $* to avoid spaces problems

* "$@" will correctly handle arguments with spaces

12 years agoAutotools: Use "set -e" to exit on the first error
Ludovic Rousseau [Fri, 4 May 2012 15:56:00 +0000 (16:56 +0100)]
Autotools: Use "set -e" to exit on the first error

* The script will not continue if something fails (like a command not found)

12 years agoAutotools: Do not use source to call an another script
Ludovic Rousseau [Fri, 4 May 2012 15:56:00 +0000 (16:56 +0100)]
Autotools: Do not use source to call an another script

* Script is valid for bash but not any /bin/sh
* Thanks to Xiaofan Chen for the bug report
http://sourceforge.net/mailarchive/message.php?msg_id=29217871

12 years agoWindows: Fix deadlock in backend when submitting transfers.
Toby Gray [Thu, 3 May 2012 10:25:11 +0000 (11:25 +0100)]
Windows: Fix deadlock in backend when submitting transfers.

Without this change the Windows backend needed to call usbi_fd_notification()
from within the backend's submit_transfer. This can cause deadlock when
attempting to lock the event lock if another thread was processing events on
the just-submitted transfer.

The deadlock comes about as the thread calling libusb_submit_transfer acquires
the transfer mutex before trying to acquire the event lock; this is the other
order of lock acquisition from an event thread handling activity on the just
submitted transfer. This could lead to one of two deadlocks:

1) If the transfer completes while usbi_fd_notification() is waiting for
the event lock and the callback attempts to resubmit the transfer.

2) If the transfer timeout is hit while usbi_fd_notification() is waiting
for the event lock then the attempt to cancel the transfer will deadlock.

This patch fixes both of these deadlocks by having libusb_submit_transfer()
only call usbi_fd_notification() after having released the transfer mutex.

12 years agoSamples: Remove interface requests when querying WCID devices
Pete Batard [Wed, 2 May 2012 17:02:50 +0000 (18:02 +0100)]
Samples: Remove interface requests when querying WCID devices

* As per MS documentation, querying of the Extended Properties
  is a device request (0xC0), not an interface one (0xC1), so
  there is no issue with the WinUSB wIndex override.

12 years agoAutotools: Add bootstrap.sh
Pete Batard [Wed, 2 May 2012 11:06:36 +0000 (12:06 +0100)]
Autotools: Add bootstrap.sh

bootstrap.sh does not invoke configure whereas autogen.sh does.
This allows libusbx users to choose the one that suits them best.

12 years agoWindows: Fix removal of usbi_fd_notification calls in submit_*_transfer
Uri Lublin [Tue, 1 May 2012 13:47:00 +0000 (14:47 +0100)]
Windows: Fix removal of usbi_fd_notification calls in submit_*_transfer

Commit 4cccbed825fe1dc13812 accidentally removed those calls,
when ! ifdef DYNAMIC_FDS blocks were removed.

12 years agoCore: update version struct for ABI compatibility
Pete Batard [Wed, 25 Apr 2012 23:30:57 +0000 (00:30 +0100)]
Core: update version struct for ABI compatibility

* Adds a static string for describe
* Also update version documentation

12 years agoLinux: Search for /dev/usbdev<bus>.<device> USB device special files
James Hanko [Thu, 20 Oct 2011 07:32:34 +0000 (00:32 -0700)]
Linux: Search for /dev/usbdev<bus>.<device> USB device special files

If neither the (now deprecated) usbfs filesystem nor udev is available
then libusbx searches for device nodes also in /dev where they may be
created if the kernel was built with the option CONFIG_USB_DEVICE_CLASS.
This helps on embedded systems such as Android, and all mdev users.

12 years agoBSD: Provide libusb_get_device_speed() data
Martin Pieuchot [Thu, 19 Apr 2012 09:33:36 +0000 (11:33 +0200)]
BSD: Provide libusb_get_device_speed() data

Because the different speed values used by the libusb and OpenBSD's
usb_device_info structure are compatible, keep the code simple and
just copy the value returned by the USB_GET_DEVICEINFO ioctl() call.

12 years agoSamples: Fix not handled in switch warning in xusb.c
Ludovic Rousseau [Fri, 20 Apr 2012 09:36:07 +0000 (11:36 +0200)]
Samples: Fix not handled in switch warning in xusb.c

xusb.c: In function ‘test_device’:
xusb.c:722:2: warning: enumeration value ‘USE_GENERIC’ not handled in switch [-Wswitch-enum]

12 years agoSamples: Remove unneeded inline in xusb.c
Ludovic Rousseau [Fri, 20 Apr 2012 09:29:50 +0000 (11:29 +0200)]
Samples: Remove unneeded inline in xusb.c

Fixes:
warning: function ‘perr’ can never be inlined because it uses variable argument lists [-Winline]
warning: inlining failed in call to ‘perr’: function not inlinable [-Winline]

12 years agoLinux: Fix signed vs unsigned compiler warnings
Ludovic Rousseau [Fri, 20 Apr 2012 21:25:38 +0000 (22:25 +0100)]
Linux: Fix signed vs unsigned compiler warnings

os/linux_usbfs.c: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

12 years agoLinux: Silence unused variable warnings without CLOCK_MONOTONIC
Xiaofan Chen [Sat, 14 Apr 2012 15:17:18 +0000 (23:17 +0800)]
Linux: Silence unused variable warnings without CLOCK_MONOTONIC

12 years agoCore: Add debug message with callback address on completed transfer
Peter Stuge [Mon, 16 Apr 2012 01:59:44 +0000 (03:59 +0200)]
Core: Add debug message with callback address on completed transfer

12 years agoBSD: add NetBSD experimental support
Pete Batard [Thu, 19 Apr 2012 17:01:04 +0000 (18:01 +0100)]
BSD: add NetBSD experimental support

* also improve OS/backend selection in configure.ac
* original libusb patches from Peter Stuge and Xiaofan Chen

12 years agolibusbx-1.0.10
Pete Batard [Tue, 17 Apr 2012 01:20:40 +0000 (02:20 +0100)]
libusbx-1.0.10

12 years agoSamples: Fix initialization discards qualifiers warnings in xusb.c
Ludovic Rousseau [Sat, 14 Apr 2012 07:27:24 +0000 (09:27 +0200)]
Samples: Fix initialization discards qualifiers warnings in xusb.c

xusb.c: In function ‘read_ms_winsub_feature_descriptors’:
xusb.c:542: warning: initialization discards qualifiers from pointer target type
xusb.c:543: warning: initialization discards qualifiers from pointer target type
xusb.c: In function ‘test_device’:
xusb.c:598: warning: initialization discards qualifiers from pointer target type
xusb.c:598: warning: initialization discards qualifiers from pointer target type
xusb.c:598: warning: initialization discards qualifiers from pointer target type
xusb.c:599: warning: initialization discards qualifiers from pointer target type
xusb.c:599: warning: initialization discards qualifiers from pointer target type

12 years agoSamples: Fix no previous prototype warnings in xusb.c
Ludovic Rousseau [Sat, 14 Apr 2012 07:24:58 +0000 (09:24 +0200)]
Samples: Fix no previous prototype warnings in xusb.c

xusb.c:139: warning: no previous prototype for ‘display_buffer_hex’
xusb.c:169: warning: no previous prototype for ‘display_ps3_status’
xusb.c:260: warning: no previous prototype for ‘display_xbox_status’
xusb.c:281: warning: no previous prototype for ‘set_xbox_actuators’
xusb.c:299: warning: no previous prototype for ‘send_mass_storage_command’
xusb.c:354: warning: no previous prototype for ‘get_mass_storage_status’
xusb.c:401: warning: no previous prototype for ‘get_sense’
xusb.c:431: warning: no previous prototype for ‘test_mass_storage’
xusb.c:530: warning: no previous prototype for ‘read_ms_winsub_feature_descriptors’
xusb.c:583: warning: no previous prototype for ‘test_device’

12 years agoMisc: Add a missing newline at end of .private/README.txt
Ludovic Rousseau [Sat, 14 Apr 2012 07:22:15 +0000 (09:22 +0200)]
Misc: Add a missing newline at end of .private/README.txt

12 years agolibusbx 1.0.10-rc1
Pete Batard [Fri, 13 Apr 2012 21:23:58 +0000 (22:23 +0100)]
libusbx 1.0.10-rc1

12 years agoWindows: add internal binary snapshot scripts
Pete Batard [Thu, 12 Apr 2012 22:52:49 +0000 (23:52 +0100)]
Windows: add internal binary snapshot scripts

12 years agoGit: add pre-commit and post-rewrite hooks for versioning
Pete Batard [Wed, 11 Apr 2012 22:12:21 +0000 (23:12 +0100)]
Git: add pre-commit and post-rewrite hooks for versioning

* Also adds the maintainer-only .private directory

12 years agoMisc: update pkg-config template
Pete Batard [Wed, 11 Apr 2012 16:44:57 +0000 (17:44 +0100)]
Misc: update pkg-config template

* Change human readable name to libusbx and mention OpenBSD

12 years agoWindows: Remove #define options and use same set of defaults
Pete Batard [Tue, 10 Apr 2012 12:30:24 +0000 (13:30 +0100)]
Windows: Remove #define options and use same set of defaults

* The DYNAMIC_FDS, AUTO_CLAIM and FORCE_INSTANT_TIMEOUTS options
  were introduced for development/testing and don't appear to be
  used by the Windows backend users => remove them.