platform/upstream/libusb.git
11 years agoCore: Don't wait for completion if cancel_transfer failed
Zoltán Kovács [Tue, 29 Jan 2013 00:14:29 +0000 (00:14 +0000)]
Core: Don't wait for completion if cancel_transfer failed

* See http://libusbx.1081486.n5.nabble.com/Libusbx-devel-libusb-interrupt-transfer-does-not-return-in-case-of-error-td626.html
* Closes #76

11 years agoWindows: Display error code in default case of windows_transfer_callback
Pete Batard [Mon, 28 Jan 2013 23:51:53 +0000 (23:51 +0000)]
Windows: Display error code in default case of windows_transfer_callback

11 years agoWinCE: Add support for WinCE (Solution files)
Toby Gray [Wed, 16 Jan 2013 02:10:31 +0000 (02:10 +0000)]
WinCE: Add support for WinCE (Solution files)

11 years agoWinCE: Add support for WinCE (sources)
Toby Gray [Wed, 16 Jan 2013 02:07:29 +0000 (02:07 +0000)]
WinCE: Add support for WinCE (sources)

11 years agoWindows: Simplify poll_windows and add provisions for WinCE
Toby Gray [Tue, 15 Jan 2013 22:46:49 +0000 (22:46 +0000)]
Windows: Simplify poll_windows and add provisions for WinCE

* Because poll_windows now requires struct usbi_transfer to be
  defined, it's inclusion in libusbi.h had to be moved down.

11 years agoWindows: Add windows_common.h header
Toby Gray [Tue, 15 Jan 2013 22:36:47 +0000 (22:36 +0000)]
Windows: Add windows_common.h header

* This file contains definition that will be shared between the
  Windows and Windows CE backends

11 years agoCore: Use HAVE_SYS_TYPES_H and HAVE_SIGNAL_H
Pete Batard [Tue, 15 Jan 2013 22:24:32 +0000 (22:24 +0000)]
Core: Use HAVE_SYS_TYPES_H and HAVE_SIGNAL_H

* These files may not be available on all platforms (eg. WinCE)

11 years agoCore: Filter out 8-bit characters in libusb_get_string_descriptor_ascii
Роман Донченко [Fri, 21 Dec 2012 23:08:09 +0000 (03:08 +0400)]
Core: Filter out 8-bit characters in libusb_get_string_descriptor_ascii

* Closes #68

11 years agoWindows: Add VS2012 solution files
Pete Batard [Mon, 7 Jan 2013 22:00:47 +0000 (22:00 +0000)]
Windows: Add VS2012 solution files

* As well as try to clean up MS's MSVC mess...

11 years agoCore: Fix incorrect reference counting of default context when first created.
Toby Gray [Mon, 26 Nov 2012 13:25:05 +0000 (13:25 +0000)]
Core: Fix incorrect reference counting of default context when first created.

* See http://libusbx.1081486.n5.nabble.com/Libusbx-devel-stress-program-crashes-in-libusb-exit-NULL-tp474p477.html

11 years agoTests: Add libusbx stress test
Toby Gray [Wed, 21 Nov 2012 14:00:31 +0000 (14:00 +0000)]
Tests: Add libusbx stress test

See https://github.com/tobygray/libusbx/tree/testing as well
as http://libusbx.1081486.n5.nabble.com/Libusbx-devel-Crashes-tt433.html#a438

11 years agoAutotools: Carry over 2012.10.23 libusb changes
Peter Stuge [Tue, 23 Oct 2012 00:15:23 +0000 (00:15 +0000)]
Autotools: Carry over 2012.10.23 libusb changes

* Use LIBS instead of PC_LIBS_PRIVATE
* Move THREAD_CFLAGS & VISIBILITY_CFLAGS into AM_CFLAGS
* Use AC_SEARCH_LIBS(clock_gettime) for pthreads on Linux

11 years agoCore: Avoid short read failures on broken descriptors
Peter Stuge [Tue, 30 Oct 2012 00:11:41 +0000 (00:11 +0000)]
Core: Avoid short read failures on broken descriptors

* See http://marc.info/?t=135132844600001&r=1&w=2

11 years agoDarwin: kAppleVendorID is not in the 10.5 SDK
Sean McBride [Thu, 8 Nov 2012 19:02:06 +0000 (19:02 +0000)]
Darwin: kAppleVendorID is not in the 10.5 SDK

* Use kIOUSBVendorIDAppleComputer instead

11 years agoDarwin: Clean up tabs
Nathan Hjelm [Wed, 31 Oct 2012 22:54:07 +0000 (22:54 +0000)]
Darwin: Clean up tabs

* Closes #55

11 years agoDarwin: Add support for detecting superspeed devices
Nathan Hjelm [Tue, 2 Oct 2012 14:07:03 +0000 (08:07 -0600)]
Darwin: Add support for detecting superspeed devices

* IOUSBFamily 5.0.0 or newer

11 years agoDarwin: Use Release instead of IODestroyPlugInInterface
Nathan Hjelm [Sat, 29 Sep 2012 04:13:09 +0000 (22:13 -0600)]
Darwin: Use Release instead of IODestroyPlugInInterface

* This avoids stopping IOServices associated with a device
* Closes #54

11 years agoDarwin: Don't retry or unsuspend Apple devices during enum
Nathan Hjelm [Sat, 29 Sep 2012 03:18:36 +0000 (21:18 -0600)]
Darwin: Don't retry or unsuspend Apple devices during enum

11 years agoDarwin: Reduce attempts to retrieve a device descriptor during enumeration
Nathan Hjelm [Sat, 29 Sep 2012 03:18:08 +0000 (21:18 -0600)]
Darwin: Reduce attempts to retrieve a device descriptor during enumeration

11 years agoCore: Use offsetof() instead of null pointer tricks
Sean McBride [Thu, 25 Oct 2012 18:51:50 +0000 (14:51 -0400)]
Core: Use offsetof() instead of null pointer tricks

Closes #53

11 years agoWindows: Fix access for composite HID devices
Pete Batard [Mon, 29 Oct 2012 23:41:23 +0000 (23:41 +0000)]
Windows: Fix access for composite HID devices

* composite_open was only catering for interfaces with WinUSB-like
  drivers and did not properly initialize HID driven ones
* Issue reported by Stefano Di Martino

11 years agoAll: Use "" instead of <> for local includes
Ludovic Rousseau [Fri, 12 Oct 2012 21:28:51 +0000 (23:28 +0200)]
All: Use "" instead of <> for local includes

System header files are used with #include <foo.h>
Xcode can't find local headers using this syntax.

11 years agoWindows: Fix early abort in libusb_close
Pete Batard [Wed, 3 Oct 2012 22:52:16 +0000 (23:52 +0100)]
Windows: Fix early abort in libusb_close

* We're calling winusbx_close with SUB_API_NOTSET, so
  we should attempt to initialize it first.
* Issue reported by Ramon Zambelli and Frank Hibbeln

11 years agolibusbx-1.0.14
Pete Batard [Mon, 24 Sep 2012 23:35:32 +0000 (00:35 +0100)]
libusbx-1.0.14

11 years agolibusbx-1.0.13
Pete Batard [Thu, 20 Sep 2012 20:58:04 +0000 (21:58 +0100)]
libusbx-1.0.13

11 years agoInternal: Add fxload exe and sources to the Windows binary snapshot
Pete Batard [Wed, 19 Sep 2012 21:22:24 +0000 (22:22 +0100)]
Internal: Add fxload exe and sources to the Windows binary snapshot

11 years agoMisc: Update copyrights, TODO and libusb_version.describe
Pete Batard [Tue, 18 Sep 2012 20:35:23 +0000 (21:35 +0100)]
Misc: Update copyrights, TODO and libusb_version.describe

* Changes suggested by Chuck Cook & Xiaofan Chen

11 years agolibusbx 1.0.13-rc2
Pete Batard [Sun, 16 Sep 2012 15:24:24 +0000 (16:24 +0100)]
libusbx 1.0.13-rc2

* Also update NEWS with regards to isoc support for the 0/K Windows drivers

11 years agoDoc: Fix doxygen warnings and issues
Pete Batard [Sun, 16 Sep 2012 15:19:54 +0000 (16:19 +0100)]
Doc: Fix doxygen warnings and issues

* Remove obsolete tags
* Use QUIET = yes to make issues more prominent
* Fix code display for LIBUSBX_API_VERSION and missing parameter
  documentation for libusb_get_port_path()
* Most of the above suggested by Ludovic Rousseau

11 years agoMisc: Fix missing files from dist package
Pete Batard [Sun, 16 Sep 2012 15:11:10 +0000 (16:11 +0100)]
Misc: Fix missing files from dist package

11 years agolibusbx 1.0.13-rc1
Pete Batard [Sat, 15 Sep 2012 23:16:06 +0000 (00:16 +0100)]
libusbx 1.0.13-rc1

11 years agoCore: Introduce LIBUSBX_API_VERSION macro
Pete Batard [Sat, 15 Sep 2012 22:57:21 +0000 (23:57 +0100)]
Core: Introduce LIBUSBX_API_VERSION macro

* This macro can be used to detect if the version of libusbx being
  compiled against has a specific API feature, as well as to detect
  whether compilation occurs against libusb or libusbx.

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

12 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.

12 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

12 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.

12 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

12 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.

12 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

12 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