Michael Plante [Fri, 23 Dec 2011 22:50:21 +0000 (16:50 -0600)]
Windows: guid_to_string() is only discarded when macro-usbi_dbg used
* usbi_dbg encloses all references to guid_to_string
* MinGW/cygwin warn about an unused function, so the #if
squelches this warning
* MSVC6 uses a variadic function form of usbi_dbg instead
of a macro, so the compiler still "sees" guid_to_string
and it therefore needs to always be defined for MSVC6,
even if it's only a stub.
* So we define it if usbi_dbg is used OR if MSVC6 is used.
Signed-off-by: Michael Plante <michael.plante@gmail.com>
Pete Batard [Tue, 15 Nov 2011 01:11:12 +0000 (01:11 +0000)]
Windows: Fix undefined datatype 'LONG_PTR' in MSVC6
* issue reported by Elmi
Signed-off-by: Michael Plante <michael.plante@gmail.com>
Pete Batard [Sun, 13 Nov 2011 23:10:15 +0000 (23:10 +0000)]
Windows: Fix for MSVC6 preprocessor not accepting blank parameters
* unlike later iterations of Visual Studio, MSVC6 does not accept
blank parameters on macro calls [eg. CALL(a, ,b)]
* blank params were used with the DLL_DECLARE and DLL_LOAD macros
* issue reported by Elmi
Michael Plante [Tue, 26 Oct 2010 10:39:38 +0000 (11:39 +0100)]
Windows: Switch MSVC6 .dsp project files from MBCS to Unicode
* MBCS (which is different from UTF-8) only makes sense if
supporting Windows 95/98, which we don't
* (try to match Pete's vcproj changes in MSVC6)
Michael Plante [Wed, 14 Dec 2011 02:39:40 +0000 (21:39 -0500)]
Windows: Add missing MSVC6 lsusb.dsp project file
Signed-off-by: Michael Plante <michael.plante@gmail.com>
Martin Pieuchot [Mon, 30 Jan 2012 08:59:30 +0000 (09:59 +0100)]
OpenBSD backend
Xiaofan Chen [Fri, 13 Jan 2012 17:07:34 +0000 (18:07 +0100)]
configure.ac: Darwin: Move -lobjc from LIBS to PC_LIBS_PRIVATE
Since commit
40327cd134718475f6cec8935b856d4fdff2099c it is neccessary
to explicitly include -lobjc not only when linking libusb itself, but
also for programs linking statically against libusb. References #63.
See also http://marc.info/?m=
132505900202378
Xiaofan Chen [Fri, 13 Jan 2012 12:04:00 +0000 (13:04 +0100)]
examples: Link only with ../libusb/libusb-1.0.la and not with -lusb-1.0
Previous _LDFLAGS included both the freshly built libusb in ../libusb
and -lusb-1.0, where libtool would usually resolve the latter to an
already-installed libusb library in the system. The extra reference
to a second libusb library resulted in failure to build examples on
Mac OS X in some cases, and is plain wrong.
See also the thread at http://marc.info/?m=
132637593623667
Peter Stuge [Thu, 12 Jan 2012 09:34:55 +0000 (10:34 +0100)]
libusb/Makefile.am: Avoid recursive variables in .rc silent-rule
Not every make supports recursive variable expansion so some automake
versions complain about non-POSIX variable names ever since commit
70bec4a9f8ec28d36c731011fa24d37c74ad3523 which added support for
silent-rules in our rule to compile the Windows .rc file.
This commit removes the recursive variables and instead uses the
simple and generic GEN message and associated variable.
Ludovic Rousseau [Sat, 24 Sep 2011 16:27:54 +0000 (18:27 +0200)]
Core: Fix #122 warning: no previous prototype for ‘usbi_log_v’
Declare the usbi_log_v() function before using it.
Sean McBride [Fri, 14 Oct 2011 18:40:29 +0000 (14:40 -0400)]
Darwin: Set a name for the background thread on Mac OS X 10.6 and later
The call to pthread_setname_np() makes it easy to identify the
background thread in the Xcode debugger and in crash reports.
Peter Stuge [Thu, 22 Sep 2011 19:42:35 +0000 (21:42 +0200)]
libusb/Makefile.am: Add libusb-1.0.rc dependency on version.h
Peter Stuge [Thu, 22 Sep 2011 19:38:29 +0000 (21:38 +0200)]
libusb/Makefile.am: Make the libusb-1.0.rc rule support silent-rules
Peter Stuge [Thu, 22 Sep 2011 19:17:37 +0000 (21:17 +0200)]
configure.ac: Enable libtool support for Windows Resource language
Sean McBride [Mon, 19 Sep 2011 16:52:44 +0000 (12:52 -0400)]
descriptor.c: Use size_t for minor 64 bit compliance improvement
Fixes #121.
Sean McBride [Mon, 19 Sep 2011 16:42:33 +0000 (12:42 -0400)]
Darwin: Fix warnings about mismatched signed/unsigned compare
References #121.
Sean McBride [Mon, 19 Sep 2011 16:38:20 +0000 (12:38 -0400)]
Fix unused variable warnings when without timerfd and/or when on Darwin
References #121.
Ludovic Rousseau [Fri, 16 Sep 2011 16:07:56 +0000 (18:07 +0200)]
Correctly handle LIBUSB_TRANSFER_OVERFLOW in libusb_control_transfer()
sync.c: In function `libusb_control_transfer':
sync.c:122: warning: enumeration value `LIBUSB_TRANSFER_OVERFLOW' not
handled in switch
Fixes #120.
Pete Batard [Mon, 19 Sep 2011 15:01:37 +0000 (16:01 +0100)]
Windows: do not set altsetting 0 as part of libusb_release_interface()
* pointed out by Travis Robinson and Xiaofan Chen
* similar to a change advised by Alan Stern for the Linux kernel:
http://marc.info/?m=
122790204410765
Pete Batard [Mon, 19 Sep 2011 14:45:35 +0000 (15:45 +0100)]
Windows: fix communication with hubs
* issue reported by René Haunstrup in http://marc.info/?m=
130503019227814
Pete Batard [Mon, 19 Sep 2011 14:41:39 +0000 (15:41 +0100)]
Windows: add USB 3.0 controller support
* Windows 8, NEC/Renesas, TI, Fresco Logic, Etron, VIA, ASMedia
(some of which untested!)
* includes workaround for NEC/Renesas USB 3.0 root hubs
Pete Batard [Mon, 19 Sep 2011 14:28:03 +0000 (15:28 +0100)]
Windows: add static keywords and drop duplicated or unneeded code
Pete Batard [Mon, 19 Sep 2011 12:59:46 +0000 (13:59 +0100)]
Windows: fix 'windows_error_str' defined but not used when not logging
Peter Stuge [Thu, 22 Sep 2011 08:19:17 +0000 (10:19 +0200)]
libusbi.h: Silence unused context variable warnings when not logging
Pete Batard [Mon, 19 Sep 2011 12:06:22 +0000 (13:06 +0100)]
Windows: copy DLL file regardless of ddk_build.cmd dll argument case
Pete Batard [Sun, 18 Sep 2011 19:06:45 +0000 (20:06 +0100)]
Windows: Add uint32_t typedef for old MSC so that DDK can build lsusb
Vitali Lovich [Fri, 16 Sep 2011 14:53:25 +0000 (08:53 -0600)]
Darwin: fix port leak in darwin_clock_gettime()
Vitali Lovich [Fri, 16 Sep 2011 14:50:40 +0000 (08:50 -0600)]
Darwin: remove unnecessary run loop invalidation during libusb_exit()
Vitali Lovich [Fri, 16 Sep 2011 14:49:54 +0000 (08:49 -0600)]
Darwin: fix port leak during libusb_exit()
Vitali Lovich [Fri, 16 Sep 2011 14:48:28 +0000 (08:48 -0600)]
Darwin: fix potential leak on libusb_claim_interface() error
Nathan Hjelm [Fri, 16 Sep 2011 14:41:01 +0000 (08:41 -0600)]
Darwin: Fix #117 transfer size 64/32 bit issue for transfer callbacks
The transfer size is now always truncated to 32 bits.
Peter Stuge [Thu, 15 Sep 2011 15:04:43 +0000 (17:04 +0200)]
Remove username from SF FRS rsync upload command
Peter Stuge [Thu, 15 Sep 2011 14:48:35 +0000 (16:48 +0200)]
Support release candidate versions in configure.ac and libusb-1.0.rc
Peter Stuge [Thu, 15 Sep 2011 14:32:47 +0000 (16:32 +0200)]
Tidy .gitignore a little
There's no xusb, we need a glob pattern for matching .exe files, and
fpusb tarballs aren't very common in the libusb source dir.
Hans de Goede [Wed, 14 Sep 2011 08:53:48 +0000 (10:53 +0200)]
Docs: Clarify that libusb_handle_events_timeout() tv param can't be NULL
The example code and API doc for libusb_handle_events_timeout() could be
interpreted as it being OK to pass a NULL pointer for the tv argument (I
interpreted it like that when I first started coding for libusb).
This patch changes the docs to make it clear that one must always supply
a tv struct to libusb_handle_events_timeout.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Peter Stuge [Wed, 14 Sep 2011 06:23:43 +0000 (08:23 +0200)]
Makefile.am: Do not remove ChangeLog on make distclean, fixes #116
[pbatard: Remove it on make maintainer-clean instead]
Vitali Lovich [Wed, 14 Sep 2011 05:02:06 +0000 (07:02 +0200)]
Darwin: Reduce race likelihood between cancellation and device disconnect
References #88. The race condition still remains, but this change
makes it less likely to trigger.
Peter Stuge [Wed, 14 Sep 2011 02:00:33 +0000 (04:00 +0200)]
Document that libusb_get_device_list() can return any libusb_error code
Fixes #87.
Pete Batard [Thu, 16 Jun 2011 09:49:13 +0000 (10:49 +0100)]
Linux: Fix #81 URB double free race condition on device disconnect
A submitted transfer that has just been failed by the kernel could be
picked up by an event handler to be cleaned up, where freeing of URB
memory would race with the submit function doing it's own cleanup and
freeing as a result of the submit failing.
libusb_submit_transfer() always holds itransfer->lock, so the race can
be avoided by taking that lock also in the cleanup path and checking
that the URB memory has not already been freed before freeing it there.
As http://libusb.org/ticket/81#comment:14 notes there is still another
possible, but unlikely, race condition between libusb_submit_transfer()
and an event handling thread. That will require more work to solve.
[stuge: Add check in cleanup path that URBs have not already been freed]
Peter Stuge [Wed, 14 Sep 2011 01:00:14 +0000 (03:00 +0200)]
Add libusb_error_name() API function
Until we have i18ned error messages we can at least offer easy
translation from numeric error code to the error code's name.
[hansg: switch() on enum to get a compiler warning if a case is missing]
[hansg: Better return value when called with an unknown error code]
[hansg: Fix DEFAULT_VISIBILITY in definition to compile on all platforms]
Peter Stuge [Wed, 14 Sep 2011 00:30:18 +0000 (02:30 +0200)]
Add libusb_has_capability() API function
Since it is currently not planned to change the filename of the libusb
library between libusb-1.0 versions at least on Windows systems it's
important to have a capability API.
Currently there exists only one capability; LIBUSB_CAP_HAS_CAPABILITY,
which tests support for the libusb_has_capability() API.
Sebastian Pipping [Tue, 13 Sep 2011 18:38:26 +0000 (20:38 +0200)]
Fix typos in introductory documentation
Pekka Nikander [Tue, 13 Sep 2011 16:57:43 +0000 (18:57 +0200)]
Linux: Add libusb_open() debug and error messages with the device path
Fixes #109.
Pekka Nikander [Tue, 13 Sep 2011 16:52:36 +0000 (18:52 +0200)]
Add debug message with libusb_open() error code
References #109.
Hans de Goede [Mon, 12 Sep 2011 16:11:20 +0000 (18:11 +0200)]
Document libusb_handle_events_completed() and _timeout_completed()
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
[stuge: Note that the old racy functions should be avoided by new code]
Graeme Gill [Sat, 10 Sep 2011 13:47:05 +0000 (15:47 +0200)]
Fix #56 race condition causing delayed completion of sync transfers
The sync API had a race where it would check a condition to know if it
needed to call a libusb_handle_events() function. However, the check
was done outside of the lock that is held while the condition is set,
so another thread could completely serve whatever was needed to make
the condition true between it being checked and the event handler being
called. This situation would be detected after a libusb-internal timeout
of 60 seconds, after which the transfer would be completed without
error, but with significant delay.
Original patch at http://marc.info/?l=libusb-devel&m=
127252114815709
Changes by Hans de Goede:
- Renamed the "race-proof" functions from libusb_handle_events*_check()
to libusb_handle_events*_completed()
- Drop r = 0 setting in libusb_handle_events_timeout_completed()
(to make both completed checking cases identical flow wise)
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
[stuge: Simplify libusb_handle_events_timeout() change with a goto]
[pbatard: Fix _handle_events_timeout() and _completed() definitions]
Nathan Hjelm [Sat, 27 Aug 2011 05:06:40 +0000 (23:06 -0600)]
Darwin: Use a condition to signal async thread ready in libusb_init()
Nathan Hjelm [Fri, 22 Jul 2011 04:34:12 +0000 (22:34 -0600)]
Fix #64 use of reserved identifiers throughout libusb
Nathan Hjelm [Fri, 22 Jul 2011 04:31:09 +0000 (22:31 -0600)]
Darwin: fix libusb_get_device_list() and libusb_claim_interface() leaks
Nathan Hjelm [Fri, 22 Jul 2011 04:28:47 +0000 (22:28 -0600)]
Darwin: use kIOMasterPortDefault instead of creating a master port
Peter Stuge [Wed, 27 Jul 2011 01:15:03 +0000 (03:15 +0200)]
Allow devices with zero configurations to be discovered
At least in Linux, wireless USB devices have zero configurations until
they have been authorized. This device state can be set for any USB
device using:
echo 0 > /sys/bus/usb/devices/?-?/authorized
An unauthorized device would previously make usbi_sanitize_device()
return LIBUSB_ERROR_IO, although there really was no I/O error.
Reported-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Peter Stuge [Wed, 27 Jul 2011 04:17:48 +0000 (06:17 +0200)]
Linux: Continue enumeration even if one device returns an error
Hans de Goede [Fri, 17 Jun 2011 08:19:00 +0000 (10:19 +0200)]
Linux: Handle single- and two-digit kernel versions like 3.0 and 4
The code has been tested with various version strings.
[stuge: Remove bogus string length check and optimize for newer kernels]
Pete Batard [Thu, 3 Mar 2011 18:35:35 +0000 (18:35 +0000)]
Windows: Provide libusb_get_device_speed() data
* use (currently superspeed unaware) USB_NODE_CONNECTION_INFORMATION_EX
Fixes #45.
[stuge: Explicitly convert OS device speeds to libusb device speeds]
[pbatard: Add breaks overlooked when adding explicit conversion]
Trygve Laugstøl [Tue, 19 Jul 2011 21:20:40 +0000 (23:20 +0200)]
Darwin: Provide libusb_get_device_speed() data
References #45.
Hans de Goede [Thu, 17 Feb 2011 14:06:40 +0000 (15:06 +0100)]
Linux: Provide libusb_get_device_speed() data from sysfs
References #45.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Hans de Goede [Thu, 17 Feb 2011 12:17:55 +0000 (13:17 +0100)]
Add new API function libusb_get_device_speed()
Reworked version of my earlier patch, largely modelled after (if not
copy and pasted from) Trygve Laugstøl's <trygvis@inamo.no> similar
commit
5a6541e0d80fb1f21e2b960bc2337a612f9d74fb in
git://git.libusb.org/libusb-trygvis.git
http://git.libusb.org/libusb-trygvis.git
http://git.libusb.org/?p=libusb-trygvis.git;a=commitdiff;h=
5a6541e0d
This patch does not add any OS specific code. The supporting code in
each backend follows in separate patches. References #45.
Signed-off-By: Hans de Goede <hdegoede@redhat.com>
Nathan Hjelm [Sun, 20 Mar 2011 06:25:44 +0000 (00:25 -0600)]
Darwin: Improve device enumeration performance
The device location is saved, and later used whenever iterating over
devices. Fixes #111 and #112.
[stuge: Formatting fixes and split out libusb_get_device_speed() change]
[stuge: Combine with patch that uses the saved device location]
Hans de Goede [Thu, 17 Feb 2011 11:49:36 +0000 (12:49 +0100)]
Linux: Use __read_sysfs_attr() to get busnum and devaddr
Remove code duplication.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Hans de Goede [Thu, 17 Feb 2011 11:45:10 +0000 (12:45 +0100)]
Linux: Add __read_sysfs_attr() helper function
On Linux we often need to read (postive) integers from sysfs. This patch
adds a helper function for this. This is a preparation patch for adding
a libusb_get_device_speed() function to libusb.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Hans de Goede [Tue, 8 Feb 2011 15:37:18 +0000 (16:37 +0100)]
Linux: Stop kernel from re-attaching in-kernel driver after reset
When an interface is bound to the usbfs driver (iow claimed), the
kernel will unbind it, and then after the reset do a device_attach
on the interface, which will bind the default in kernel driver to
the interface.
So if an app has detached the in kernel driver, and claimed the
interface and then does a libusb_reset_device. Things end up with
the interface no longer being bound to the usbfs driver (so no longer
claimed) and instead it is bound to the in kernel driver (iow the in
kernel driver is re-attached).
We can stop this from happening by releasing all claimed interfaces
before the reset, as the kernel will not do the device attach after
reset, if no driver was bound to the interface before the reset.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Hans de Goede [Thu, 17 Feb 2011 11:35:46 +0000 (12:35 +0100)]
Core: Use USB_MAXINTERFACES rather then sizeof(claimed_interfaces)
claimed_interfaces is a long and thus its size differs on 32
versus 64 bits, this patch uses USB_MAXINTERFACES instead of
sizeof(claimed_interfaces) on interface number range checks
for consistent behavior independent of the arch.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Hans de Goede [Wed, 9 Feb 2011 11:40:35 +0000 (12:40 +0100)]
Linux: Fix warnings seen when compiling with gcc-4.6
Compiling with gcc-4.6 results in the following warnings:
os/linux_usbfs.c: In function 'op_get_configuration':
os/linux_usbfs.c:1144:6: warning: variable 'r' set but not used ...
os/linux_usbfs.c: In function 'op_handle_events':
os/linux_usbfs.c:2091:40: warning: 'status' may be used uninitialized ...
os/linux_usbfs.c:2044:6: note: 'status' was declared here
dpfp.c: In function 'save_to_file':
dpfp.c:228:9: warning: variable 'ignore' set but not used ...
dpfp_threaded.c: In function 'save_to_file':
dpfp_threaded.c:257:9: warning: variable 'ignore' set but not used ...
This patch fixes these. (The second comes from handle_control_completion()
which gcc seems to inline into op_handle_events().)
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
[stuge: Add fixes for dpfp examples and update source references]
Vitali Lovich [Tue, 14 Jun 2011 06:51:57 +0000 (08:51 +0200)]
Darwin: Fix #108 crash when a device is unplugged
Peter Stuge [Mon, 13 Jun 2011 20:58:23 +0000 (22:58 +0200)]
libusb.h: Add missing LIBUSB_CLASS_ codes currently defined by usb.org
LIBUSB_CLASS_PHYSICAL
LIBUSB_CLASS_SMART_CARD
LIBUSB_CLASS_CONTENT_SECURITY
LIBUSB_CLASS_VIDEO
LIBUSB_CLASS_PERSONAL_HEALTHCARE
LIBUSB_CLASS_DIAGNOSTIC_DEVICE
Per http://www.usb.org/developers/defined_class
Peter Stuge [Mon, 13 Jun 2011 20:53:40 +0000 (22:53 +0200)]
libusb.h: Add LIBUSB_CLASS_IMAGE in addition to LIBUSB_CLASS_PTP
The old LIBUSB_CLASS_PTP name is kept for compatibility. Fixes #106.
Peter Stuge [Mon, 13 Jun 2011 20:52:48 +0000 (22:52 +0200)]
libusb.h: Fix LIBUSB_CLASS_PRINTER description typo
References #106.
Sean McBride [Fri, 11 Feb 2011 16:28:04 +0000 (11:28 -0500)]
Darwin: Fix #100 warning cast to pointer from integer of different size
Sean McBride [Mon, 13 Jun 2011 20:26:43 +0000 (22:26 +0200)]
configure.ac: Fix #97 clang warning about -fgnu89-inline
Remove the test that sets the flag since GNU89 inline semantics are not
required by libusb.
[stuge: Also remove reference to the test result]
Pete Batard [Tue, 14 Jun 2011 23:38:58 +0000 (01:38 +0200)]
Windows: Make cancel_io() in poll_windows.c static
References #97.
Peter Stuge [Mon, 13 Jun 2011 20:21:02 +0000 (22:21 +0200)]
Windows: Make upperize() in windows_usb.h static
References #97.
Vitali Lovich [Thu, 17 Mar 2011 00:33:57 +0000 (17:33 -0700)]
descriptor.c: Fix buffer read overflow caught by valgrind
In parse_interface() an unexpected descriptor would be parsed without
validating the descriptor's length. It is possible for size to be 0 at
this point, which means that the parsing would read past the end of the
source buffer. Fix #83 by checking the length of the remaining buffer
before parsing.
Vitali Lovich [Thu, 17 Mar 2011 02:51:40 +0000 (19:51 -0700)]
Clean up in-flight transfers and device handle when closing a device
Any in-flight transfers should properly invalidate their references
to device handles that are being closed. Additionally, they should be
removed from the transfer-in-flight list. This is done with the events
lock held to protect against another thread processing the same transfer.
The events lock is initialized as a recursive mutex, because the device
close code might itself be called while an event is being handled.
Fixes #82.
[stuge: Trivial rework to reduce indenting]
Vitali Lovich [Thu, 17 Mar 2011 02:43:30 +0000 (19:43 -0700)]
Add recursive mutexes to threading abstraction
This is necessary for the device close path which needs to attain the
events lock, but which might itself be called while handling an event.
The events lock is necessary to properly clean up transfers which might
still be pointing to the device. References #82.
[stuge: Move usbi_mutex_init_recursive() into threads_posix.c]
[stuge: Must also #define _XOPEN_SOURCE 500 to be able to build]
[pbatard: Un-inline usbi_mutex_init_recursive() to make Cygwin happy]
Vitali Lovich [Thu, 17 Mar 2011 02:48:35 +0000 (19:48 -0700)]
Add USBI_TRANSFER_CANCELLING and _DEVICE_DISAPPEARED status flags
The flags are used to indicate if a cancellation has started, and if
a cancellation has failed because the device is no longer available.
References #82.
Vitali Lovich [Thu, 17 Mar 2011 02:50:04 +0000 (19:50 -0700)]
Linux: Detect and report that device has gone away while discarding URBs
Return LIBUSB_ERROR_NO_DEVICE if the device is no longer available
(ENODEV) to discard the urbs. References #82.
Peter Stuge [Mon, 6 Jun 2011 00:46:46 +0000 (02:46 +0200)]
libusbi.h: Add comma after last value in enum usbi_transfer_flags
Peter Stuge [Sun, 5 Jun 2011 21:28:07 +0000 (23:28 +0200)]
threads_posix.h: Whitespace fix
Peter Stuge [Sun, 5 Jun 2011 21:21:08 +0000 (23:21 +0200)]
libusb/Makefile.am: Correct threading files in libusb_1_0_la_SOURCES
Alan Ott [Thu, 21 Jul 2011 14:37:48 +0000 (16:37 +0200)]
Linux: Fix #70 race condition in sysfs_get_device_list()
Change the way libusb chooses between using sysfs and usbfs for information
about the attached devies. Using the old method, a race condition could
occur if a device was unplugged just before (or during) the call to
libusb_get_device_list(), corrupting the internal sysfs_can_relate_devices
and sysfs_has_descriptors variables and preventing libusb_get_device_list()
from working in future calls.
The old method was based on the assumption that if certain sysfs files
(eg: busnum) could not be opened, that indicated an inadequacy of sysfs
(ie: the running kernel's sysfs version did not contain those files),
when in reality those files couldn't be opened because the device had
been unplugged.
The new method checks the adequacy of sysfs during libusb_init()
(op_init()) and if a sysfs file cannot be opened, it is now assumed that
it is because the device has been unplugged, not because sysfs is
inadequate.
Signed-off-by: Alan Ott <alan@signal11.us>
[stuge: Include closedir() bugfix posted in ticket by Arne Laansoo]
[stuge: Remove dead code in sysfs_scan_device() found by Hans de Goede]
Sean McBride [Thu, 10 Feb 2011 22:11:29 +0000 (17:11 -0500)]
Darwin: Fix #63 error when apps use Objective-C garbage collection
Sean McBride [Fri, 5 Feb 2010 16:50:34 +0000 (11:50 -0500)]
Darwin: Fix #28 clang analyzer warning about unbalanced retain/release
Sean McBride [Fri, 5 Feb 2010 16:50:34 +0000 (11:50 -0500)]
io.c: Fix clang analyzer warning about unused variable
References #28.
Peter Stuge [Tue, 10 May 2011 08:44:18 +0000 (10:44 +0200)]
.gitignore: Add m4 subdirectory created by libtool
Ludovic Rousseau [Mon, 15 Nov 2010 13:45:50 +0000 (14:45 +0100)]
Linux: Do not include useless pthread.h
The code does not use threads so no need to #include <pthread.h>
Fixes #74.
Pete Batard [Tue, 8 Mar 2011 17:41:05 +0000 (17:41 +0000)]
Windows: minor code improvements
* mostly warnings from VS2010's Intellisense
Pete Batard [Tue, 8 Mar 2011 17:40:39 +0000 (17:40 +0000)]
Windows: prevent set_configuration request from being sent using WinUSB
* multiple WinUSB set configuration requests can stall a device and
WinUSB does not support setting of alt configuration in the first place
* issue reported and investigated by Xiaofan Chen
Graeme Gill [Tue, 8 Mar 2011 17:39:16 +0000 (17:39 +0000)]
Windows: fixed default WinUSB timeout and ineffective policy settings
* default WinUSB timeout was 5 seconds, which may be to small.
PIPE_TRANSFER_TIMEOUT policy is now set to infinite for all EPs.
* other WinUSB policy settings were called before the endpoints
had been set. This is now fixed.
Pete Batard [Tue, 8 Mar 2011 17:37:40 +0000 (17:37 +0000)]
Windows: Don't leak pipe fds
use _open() and _close() rather than _open_osfhandle() and CloseHandle()
* use of CloseHandle() prevented the pipe fds from being
relinquished on libusb_exit()
* leaked fds could lead to the OS running out of new fds
and LIBUSB_ERROR_NO_MEM being returned as a result
* using _open() avoids _open_osfhandle() redef for cygwin
* issue reported by Stephano Antonelli
Peter Stuge [Tue, 10 May 2011 08:05:29 +0000 (10:05 +0200)]
Windows: enumeration overhaul
* uses multiple passes in a single call
* uses a hash table, in anticipation for hotplug
* adds a (dummy) HUB interface for harmonization
* adds calloc on device struct creation in core
(to detect and avoid unnecessary double initialization)
Pete Batard [Mon, 9 May 2011 23:56:18 +0000 (00:56 +0100)]
Windows: MS project files part 4 - MSVC6 project files
Fixes #57 and #1.
Pete Batard [Mon, 9 May 2011 23:53:09 +0000 (00:53 +0100)]
Windows: MS project files part 3 - VS2005 project files
References #57.
Pete Batard [Mon, 9 May 2011 23:38:49 +0000 (00:38 +0100)]
Windows: MS project files part 2 - WDK project files
References #57.
Pete Batard [Mon, 9 May 2011 23:38:12 +0000 (00:38 +0100)]
Windows: MS project files part 1 - support files & preliminaries
* adds the MSVC support files used by MSVC6, VS2005 and WDK
* also adds missing defines required by MS compilers in libusb.h
* also anticipatory sets .gitattributes for CRLF handling
* also adds manually maintained .def file for import lib generation
References #57.
Peter Stuge [Mon, 9 May 2011 06:12:24 +0000 (08:12 +0200)]
Move library version number from configure.ac to libusb/version.h
This is neccessary to support native MS builds. The Windows resource
file libusb/libusb-1.0.rc must include the release version, which was
previously only available after configure had run and had substituted
the numbers into a generated libusb/libusb-1.0.rc file.
The version atoms are now stored as CPP style #defines in libusb/version.h
so that the .rc no longer needs to be generated but can simply include the
header file and access the version information directly.
The m4 macro LU_DEFINE_VERSION_ATOM() was added to configure.ac to get
version atoms from libusb/version.h for use in AC_INIT(). The macro
handles C and C++ style comments in version.h, but can easily be made
to fail by obscuring the file. Please don't do that.
Tested with MinGW using autoconf, and manual compile of libusb-1.0.rc
using RC.EXE Version 5.2.3690.0 from Visual C++ 2005 Express Edition.
Peter Stuge [Tue, 10 May 2011 06:36:32 +0000 (08:36 +0200)]
Windows: Debug builds create the same .dll file name as non-debug
Thanks to Pete for pointing this out!
Pete Batard [Tue, 8 Mar 2011 17:18:48 +0000 (17:18 +0000)]
Windows: explicit use of ANSI or WideChar calls
* This is in anticipation of adding MSVC project files
that use Unicode rather than MBCS
Pete Batard [Tue, 8 Mar 2011 17:16:23 +0000 (17:16 +0000)]
Windows: Remove SetupAPI, AdvAPI32 and OLE32 link-time dependencies
* this ensures that libusb dependent applications only need
to explicitly link against libusb on Windows
The run-time dependency on Cfgmgr32.dll, OLE32.dll and SetupAPI.dll remains.
Pete Batard [Tue, 8 Mar 2011 17:12:33 +0000 (17:12 +0000)]
Add .gitattributes to avoid Windows line ending issues with autocrlf
Peter Stuge [Sun, 27 Feb 2011 08:37:54 +0000 (09:37 +0100)]
Windows: Touch up FileDescription and ProductName resource strings