752 Commits

Author SHA1 Message Date
Pete Batard 302aee7d0c [internal] bumped internal version pbr342 2011-09-06 12:30:22 +01:00
Pete Batard 3fbf9a9b69 [samples] return NULL in dpfp_threaded poll_thread_main to avoid Cygwin warning 2011-09-06 12:29:55 +01:00
Vitali Lovich a6479690a3 [contrib] add non-officially supported CMake support 2011-09-06 12:18:58 +01:00
Peter Stuge 4504b66235 add missing LIBUSB_CLASS codes 2011-09-06 12:15:25 +01:00
Pete Batard 50ba04d3ec get_device_speed fixes and addons
* fixed typos and missing breaks
* device_speed in .def
* device_speed in xusb
2011-09-06 12:00:42 +01:00
Nathan Hjelm 48c695606e Darwin: Optimize device iteration further using saved device location 2011-09-06 11:11:13 +01:00
Trygve Laugstøl 037234078b Darwin: Provide libusb_get_device_speed() data 2011-09-06 11:09:35 +01:00
Nathan Hjelm bf12efb464 Darwin: Improve device enumeration performance and save device location
[stuge: Formatting fixes and split out libusb_get_device_speed() change]
2011-09-06 11:09:23 +01:00
Pete Batard 4fe08970e2 Windows: Provide libusb_get_device_speed() data
* use (currently superspeed unaware) USB_NODE_CONNECTION_INFORMATION_EX

[stuge: Explicitly convert OS device speeds to libusb device speeds]
2011-09-06 11:02:40 +01:00
Hans de Goede 605c730422 Linux: Provide libusb_get_device_speed() data from sysfs
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-09-06 10:53:53 +01:00
Hans de Goede c384ec68aa 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.

Signed-off-By: Hans de Goede <hdegoede@redhat.com>
2011-09-06 10:53:23 +01:00
Hans de Goede 328d9fd76a Linux: Use __read_sysfs_attr() to get busnum and devaddr
Remove code duplication.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-09-06 10:43:10 +01:00
Hans de Goede f471c635db 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>
2011-09-06 10:42:58 +01:00
Hans de Goede bec707ec82 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>
2011-09-06 10:41:37 +01:00
Hans de Goede 01d425426b 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>
2011-09-06 10:41:25 +01:00
Hans de Goede 1545bc6a40 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]
2011-09-06 10:41:13 +01:00
Sean McBride 1b52e6f1a1 Darwin: Fix #100 warning cast to pointer from integer of different size 2011-09-06 10:35:27 +01:00
Sean McBride 9da384914d 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]
2011-09-06 10:33:31 +01:00
Sean McBride 2934cf3604 Darwin: Fix #63 error when apps use Objective-C garbage collection 2011-09-06 10:31:26 +01:00
Sean McBride 71b380b0b0 Darwin: Fix #28 clang analyzer warning about unbalanced retain/release 2011-09-06 10:30:18 +01:00
Sean McBride 5e36dd39bf io.c: Fix clang analyzer warning about unused variable
References #28.
2011-09-06 10:28:51 +01:00
Ludovic Rousseau 77f501d917 Do not include useless pthread.h
The code does not use threads so no need to #include <pthread.h>
Fixes #74.
2011-09-05 12:49:55 +01:00
Alan Ott ee411c5195 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]
2011-09-05 12:48:01 +01:00
Vitali Lovich e28b097e75 Darwin: Fix #108 crash when a device is unplugged 2011-09-05 12:44:58 +01:00
Vitali Lovich aa282fe9d5 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.
2011-09-05 12:44:47 +01:00
Vitali Lovich 5c87b9c617 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]
2011-09-05 12:44:34 +01:00
Vitali Lovich 1ff39e34d4 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.
2011-09-05 12:44:08 +01:00
Vitali Lovich b3a2b5104e 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.
2011-09-05 12:39:43 +01:00
Vitali Lovich c4a3b026a3 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.
2011-09-05 12:35:19 +01:00
Pete Batard ea2edfcc46 some inlines were not declared as static 2011-08-23 22:56:23 +01:00
Pete Batard 3f01384271 [internal] bumped internal version pbr341 2011-07-20 14:02:16 +01:00
Pete Batard 3d28b44131 [enum] fixed duplicate listing of devices
* usb_class[class_index] could be used with out of bound index
* issue introduced with 0ffb89ce6a
* issue reported by Xiaofan Chen
2011-07-20 14:01:28 +01:00
Pete Batard 2987ce8913 [internal] bumped internal version pbr340 2011-07-06 22:48:09 +01:00
Alan Stern cf0c842214 [linux] add topology-analysis code to Linux backend
* Determines the port_number and parent_dev fields for each
  device found by sysfs_get_device_list().
2011-07-06 22:34:48 +01:00
Alan Stern b5c9800bbd [xusb] use bulk endpoints only for testing
* also reverts to using first endpoint found rather than last
2011-07-06 22:33:10 +01:00
Pete Batard 0ffb89ce6a [enum] workaround for non listing of 3.0 Renesas root hubs
* Current Nec/Renesas USB 3.0 driver lists root hubs under
  the "NUSB3" PnP Symbolic Name
* This results in root hubs not being acknowledged during enum
2011-07-06 22:18:35 +01:00
Pete Batard 8031a1df35 [xusb] switched default log level to info
* this is the recommended level to run sample applications
2011-07-04 12:29:42 +01:00
Pete Batard ca1b312b19 [internal] bumped internal version pbr339 2011-06-29 11:51:26 +01:00
Hans de Goede 9509d1fb85 [enum] remove duplicate address assignation 2011-06-28 11:59:19 +01:00
Pete Batard 11c2d76a3e [xusb] fixed xusb no longer detaching driver on Linux
* OS_LINUX is no longer defined as it came from config.h
2011-06-28 11:56:03 +01:00
Pete Batard d65eef68d3 [enum] added additional USB 3.0 hub driver names 2011-06-28 11:50:47 +01:00
Pete Batard 2537696069 [enum] added the new USB 3.0 Windows hub service name
* Microsoft has changed the service name for 3.0 hubs
* not identifying 3.0 hubs could result in a "device only
  detected in late pass - ignoring" message
* issue reported by Dave Camarillo
2011-06-08 11:05:13 +01:00
Pete Batard 43ff4ddbc1 [internal] bumped internal version pbr338 2011-05-10 20:21:59 +01:00
Pete Batard 0047081255 [MinGW] fixed warning about dev_info
* MinGW wrongly complains that dev_info may be used
  uninitialized in windows_get_device_list()
2011-05-10 19:26:31 +01:00
Pete Batard e4eeafff4f [misc] set internal windows function as static 2011-05-10 19:09:12 +01:00
Pete Batard f374e41abe [windows] remove call to set_interface_altsetting on interface release
* pointed out by Travis Robinson and Xiaofan Chen
* similar to a change advised Alan Stern for libusb-1.0/Linux:
  http://libusb.6.n5.nabble.com/RFC-Skip-sending-Set-Interface-during-driver-unbinding-td6073.html
2011-05-10 18:13:18 +01:00
Pete Batard 40f36912a1 [enum] fixed initialization of interfaces for WinUSB hub access
* also removed unneeded winusb_handle assignation
* issue reported by René Haunstrup
2011-05-10 18:05:43 +01:00
Peter Stuge 993c17da45 [wdk] fixed path for .rc in libusb_sources 2011-05-10 15:05:33 +01:00
Pete Batard 6ffaea6307 [internal] modified _bump script pbr337 2011-05-09 21:43:10 +01:00
Pete Batard fb7c03b1c7 Move library release version number from configure.ac to libusb/version.h 2011-05-09 21:39:14 +01:00