History log of /freebsd-current/lib/libusb/libusb10.c
Revision Date Author Comments
# 2a63c3be 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c comment pattern

Remove /^/[*/]\s*\$FreeBSD\$.*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 4c6bcffd 26-Jan-2023 Hans Petter Selasky <hselasky@FreeBSD.org>

libusb(3): Implement libusb_init_context() and the needed structures and definitions.

Differential Revision: https://reviews.freebsd.org/D38212
MFC after: 1 week
Sponsored by: NVIDIA Networking


# aa87aa52 02-Oct-2022 Hans Petter Selasky <hselasky@FreeBSD.org>

libusb(3): Implement libusb_interrupt_event_handler() by exposing existing function.

MFC after: 1 week
Sponsored by: NVIDIA Networking


# d94d94e2 01-Mar-2022 Hans Petter Selasky <hselasky@FreeBSD.org>

libusb(3): Ignore SIGPIPE when initializing the LibUSB v1.0 API.

The LibUSB v1.0 emulation layer uses pipes internally to signal between
threads. When USB devices are reset, as part of loading firmware, SIGPIPE
may happen, and that is expected and should be ignored.

PR: 261891
MFC after: 1 week
Sponsored by: NVIDIA Networking


# 6847ea50 11-Jun-2021 Hans Petter Selasky <hselasky@FreeBSD.org>

Improve handling of USB device re-open in the LibUSB v1.x API.

Make sure the "device_is_gone" flag is cleared after every successful open,
so that the "device_is_gone" flag doesn't persist forever.

Found by: sergii.dmytruk@3mdeb.com
PR: 256296
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking


# 04391da3 09-Jun-2020 Kyle Evans <kevans@FreeBSD.org>

libusb: improve compatibility

Specifically, add LIBUSB_CLASS_PHYSICAL and the libusb_has_capability API.
Descriptions and functionality for these derived from the
documentation at [0]. The current set of capabilities are all supported by
libusb.

These were detected as missing after updating net/freerdp to 2.1.1, which
attempted to use both.

[0] http://libusb.sourceforge.net/api-1.0/group__libusb__misc.html

Reviewed by: hselasky
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25194


# 8495fa08 02-Oct-2019 Kyle Evans <kevans@FreeBSD.org>

libusb: LIBUSB_DEBUG environment variable override of libusb_set_debug

The debug level generally just controls verbosity of libusb for debugging
libusb devices/usage. We allow the environment to set the debug level
independent of the application, but the application will always override
this if it explicitly sets the debug level.

Changing the environment is easy, but patching the software to change the
debug level isn't necessarily easy or possible. Further, there's this
write-only debug_fixed variable that would seem to imply that the debug
level should be fixed, but it isn't currently used. Change the logic to use
strtol() so we can detect real 0 vs. conversion failure, then honor
debug_fixed in libusb_set_debug.

Reviewed by: hselasky
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D21877


# 1efeb40d 05-Mar-2019 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix typos in libusb.

Found by: Denis Ahrens <denis@h3q.com>
MFC after: 1 week
Sponsored by: Mellanox Technologies


# 540c7229 12-Sep-2018 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix issues about cancelling USB transfers in LibUSB when the USB device has
been detached. When a USB device has been detached the kernel file handle
stops responding to commands. USB applications which continue to run after
the USB device has been detached, depend on LibUSB generated events to tear
down its pending USB transfers. Add code to handle the needed cleanup when
processing the USB transfer(s) fails and prevent new USB transfer(s) from
being submitted.

Found by: Ludovic Rousseau <ludovic.rousseau+freebsd@gmail.com>
PR: 231076
MFC after: 1 week
Approved by: re (gjb)
Sponsored by: Mellanox Technologies


# 5e53a4f9 25-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

lib: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using mis-identified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.


# a2aef24a 29-Oct-2017 Eitan Adler <eadler@FreeBSD.org>

Update several more URLs

- Primarily http -> https
- Primarily FreeBSD project URLs


# a0c93fa3 23-Jun-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Add support for USB streams to the LibUSB v1.0 API and update the
libusb(3) manual page.

Approved by: re (gjb)
Requested by: swills
MFC after: 1 week


# 7bdc064b 22-Jun-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Implement libusb_hotplug_register_callback() and
libusb_hotplug_deregister_callback() for the LibUSB v1.0 API and
update the libusb(3) manual page.

Approved by: re (kib)
Requested by: swills
MFC after: 1 week


# a3d81a8a 16-Jun-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Add missing return statement.

Approved by: re (gjb)
MFC after: 1 week


# 5b40d960 16-Jun-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Add support for libusb_set_auto_detach_kernel_driver() to the LibUSB v1.0 API.

Approved by: re (kostikbel)
Requested by: swills
MFC after: 1 week


# 0f2c7066 15-Jun-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Add support for libusb_get_port_number() to the LibUSB v1.0 API.

Approved by: re (kostikbel)
Requested by: swills
MFC after: 1 week


# 14b896ce 16-Jun-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Implement libusb_get_version() and update libusb manual page.

Approved by: re (glebius)
Requested by: swills
MFC after: 1 week


# 90988efd 12-Jun-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Implement code to stop all USB endpoints before executing a USB device
reset command, alternate setting command or set configuration
command. Else LibUSB v1.0 will not re-open the endpoints which the
kernel closes and the USB application might wait infinitely for
transfers to complete.

Approved by: re (hrs)
MFC after: 3 days


# 721d6da7 23-Jun-2015 Marcelo Araujo <araujo@FreeBSD.org>

Remove unused variables to silence CLANG warnings.
Remove some BLANK lines and unnecessary TABS.

Differential Revision: D2687
Reviewed by: rodrigc, hselasky


# f355a4dd 11-Apr-2014 Hans Petter Selasky <hselasky@FreeBSD.org>

Tune buffer sizes for SuperSpeed USB when using LibUSB v0.1 and v1.0
APIs to increase the maximum bandwidth limit.

MFC after: 1 week


# 7766d568 28-Jan-2014 Hans Petter Selasky <hselasky@FreeBSD.org>

Comply to the official LibUSB v1.0 API:
"It is legal to attempt to claim an already-claimed interface."

MFC after: 1 week


# a9205626 07-Jun-2013 Ed Maste <emaste@FreeBSD.org>

Add libusb_get_port_numbers

libusbx deprecated libusb_get_port_path and replaced it with
libusb_get_port_numbers. The latter omits an extra parameter which was
unused in the FreeBSD implementation anyway.


# 5906bf49 07-May-2013 Ed Maste <emaste@FreeBSD.org>

Add libusb_get_port_path wrapper

This follows the libusbx API reference at
http://libusbx.sourceforge.net/api-1.0/group__dev.html

Reviewed by: hselasky@


# 66194130 12-Mar-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

- Make the FreeBSD's USB library compile under Linux.
- Fix a compile warning where the return value of a call
to a write() function was ignored.
- Remove redundant include files from userland USB header files.
- Add some now needed include files to various C-files.


# f7287225 12-Jun-2012 Hans Petter Selasky <hselasky@FreeBSD.org>

LibUSB v1.0 API compiliance and bugfixes.

- Use CLOCK_MONOTONIC instead of CLOCK_REALTIME, because CLOCK_MONOTONIC
does not wrap into negative in near future. This fixes any potential
problems using "pthread_cond_timedwait()".

- Fix a bug where the "libusb_wait_for_event()" function computes an
absolute timeout instead of a relative timeout. USB transfers do
not depend on this timeout value.

- Add dependency towards LibPthread to Makefile, because LibUSB v1.0
needs this library to function correctly.

MFC after: 1 week


# 85ff9a03 25-Apr-2012 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix binary compatibility to the official LibUSB 1.0.
This is useful for GNU/kFreeBSD and the libusb2debian port.
Applications using the asynchronous API of LibUSB 1.0 needs
to be recompiled after this update.

Found by: lme @


# d81535d1 20-Apr-2012 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix some compile warnings.

MFC after: 1 week


# 748205a3 12-Apr-2012 Hans Petter Selasky <hselasky@FreeBSD.org>

Add missing LibUSB 1.0 API function.

Reported by: lme @
MFC after: 1 week


# 3f709d07 03-Dec-2011 Hans Petter Selasky <hselasky@FreeBSD.org>

Simplify libusb_open_device_with_vid_pid(): Only set
pdev to non-NULL on success instead of unconditonally
setting it and maybe resetting it later.

Submitted by: Christoph Mallon
MFC after: 3 days


# dc934803 03-Dec-2011 Hans Petter Selasky <hselasky@FreeBSD.org>

libusb_open() sets the given device handle to NULL if it
fails, so there is no need to do it again after returning.

Submitted by: Christoph Mallon
MFC after: 3 days


# 4d2472aa 10-Oct-2011 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix how libusb20_dev_kernel_driver_active() and
libusb_dev_kernel_driver_active() works. In case of
libusb20 the manpage was wrong and in case of
libusb10 the implementation was wrong.

Submitted by: Kai Wang
MFC after: 3 days


# c61f2561 19-Sep-2011 Hans Petter Selasky <hselasky@FreeBSD.org>

Implement missing USB debug information functions.

Approved by: re (kib)
MFC after: 1 week


# 33ec9f0c 20-Aug-2011 Hans Petter Selasky <hselasky@FreeBSD.org>

Use correct enum instead of constant value.

MFC after: 1 week
Spotted by: scf @
Approved by: re (kib)


# 9a46d467 16-Aug-2011 Hans Petter Selasky <hselasky@FreeBSD.org>

Add missing function to get device speed to the LibUSB v1.0 API.

MFC after: 1 week
Approved by: re (kib)


# 4eb5923d 16-Jul-2011 Hans Petter Selasky <hselasky@FreeBSD.org>

- Add two missing functions to the LibUSB v0.1 API.
- Clamp the string length to 255 bytes when getting
the interface description.
- Clamp data request length to 65535 bytes when doing
control requests.

MFC after: 3 days


# a7e048a2 28-Jun-2011 Hans Petter Selasky <hselasky@FreeBSD.org>

LibUSB v1.0: Need at least one frame when doing the dummy open
else clear stall won't work in that case.


# 1c497368 28-Feb-2011 Hans Petter Selasky <hselasky@FreeBSD.org>

- Add support for software pre-scaling of ISOCHRONOUS transfers.

MFC after: 14 days
Approved by: thompsa (mentor)


# 31f7072c 13-Nov-2010 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix LibUSB v1.0 compliancy.

1) We need to allow the USB callback to free the USB transfer itself.
2) The USB transfer buffer should only be automatically freed when
freeing the USB transfer.

Fixed by: hselasky
Submitted by: Gustau Perez i Querol
Approved by: thompsa (mentor)


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 698e791a 14-Oct-2010 Hans Petter Selasky <hselasky@FreeBSD.org>

- Add missing LibUSB API functions:
* libusb_strerror()
* libusb_get_driver[_np]()
* libusb_detach_kernel_driver[_np]()
- Factor out setting of non-blocking flag inside libusb.
- Add missing NULL check after libusb_get_device() call.
- Correct some wrong error codes due to copy and paste error.

PR: usb/150546
Submitted by: Robert Jenssen, Alexander Leidinger
Approved by: thompsa (mentor)


# f1b5fa6e 14-Oct-2010 Hans Petter Selasky <hselasky@FreeBSD.org>

LibUSB (new API):
- Add a new API function to check the connected
status of the USB handle in the LibUSB v1.0 and
LibUSB v0.1 interfaces.

Approved by: thompsa (mentor)


# 005044bd 17-May-2010 Andrew Thompson <thompsa@FreeBSD.org>

MFC r208020

Fix header file compliancy with libusb 1.0 from sourceforge.


# 9c087c5a 12-May-2010 Andrew Thompson <thompsa@FreeBSD.org>

Fix header file compliancy with libusb 1.0 from sourceforge.

Reported by: Xiaofan Chen
Submitted by: Hans Petter Selasky


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# f3cba95c 13-Feb-2010 Wojciech A. Koszek <wkoszek@FreeBSD.org>

Resort includes to match style(9) a bit more. No functional change
is expected after this commit.

Tested by: make buildworld
Reviewed by: hps (patch without .h changes)


# ac840bfc 11-Feb-2010 Wojciech A. Koszek <wkoszek@FreeBSD.org>

Use more standard way for setting nonblocking flag for a filedescriptor.
This makes libusb porting a bit easier.

There shouldn't by any negative change in behaviour after this commit.

Remove redundant headers.

Reviewed by: hps@


# 86a2af8f 20-Dec-2009 Sean Farley <scf@FreeBSD.org>

Merge from head to stable/8:

r200424:
Fix libusb_open_device_with_vid_pid() to return a NULL if no device is
found instead of the last device in its search list.

Reviewed by: thompsa


# abdbb3fe 11-Dec-2009 Sean Farley <scf@FreeBSD.org>

Fix libusb_open_device_with_vid_pid() to return a NULL if no device is
found instead of the last device in its search list.

Reviewed by: thompsa
MFC after: 5 days


# 4b56fe67 09-Dec-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFC r199575

- fix a transfer cancelling bug/segfault [1]
- correct a return code in the transfer cancel function.
- add new API function, libusb20_tr_bulk_intr_sync().

Submitted by: HPS
Reported by: Robert Jenssen [1]


# 4594d907 20-Nov-2009 Andrew Thompson <thompsa@FreeBSD.org>

Sync to P4
- fix a transfer cancelling bug/segfault [1]
- correct a return code in the transfer cancel function.
- add new API function, libusb20_tr_bulk_intr_sync().

Submitted by: HPS
Reported by: Robert Jenssen [1]


# 1110a460 10-Nov-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFC r199055

- fix refcounting error during data transfer
- fix a memory leak on the USB backend
- fix invalid pointer computations (in one case memory outside the allocated
area was written in LibUSB v1.0)
- make sure memory is always initialised, also in failing cases
- add missing functions from v1.0.4

PR: usb/140325


# ccef4ddf 08-Nov-2009 Andrew Thompson <thompsa@FreeBSD.org>

- fix refcounting error during data transfer
- fix a memory leak on the USB backend
- fix invalid pointer computations (in one case memory outside the allocated
area was written in LibUSB v1.0)
- make sure memory is always initialised, also in failing cases
- add missing functions from v1.0.4

PR: usb/140325
Reported by: Robert Jenssen
Submitted by: Hans Petter Selasky
MFC After: 3 days


# 390065b1 29-Jul-2009 Alfred Perlstein <alfred@FreeBSD.org>

LibUSB v1.0:

- Significantly improve libusb10 support.
- Many minor issues fixed.
- P4 ID: 166189, 165853, 165991, 166052, 166069

Submitted by: hps
Approved by: re


# c500e4dd 10-Jul-2009 Andrew Thompson <thompsa@FreeBSD.org>

Sync the libusb 1.0 exported api to the latest GSoC code.

- Fix possible uninitialised variables and null derefs
- Support big transfers
- Various bug fixes and style changes

Submitted by: Sylvestre Gallon
Sponsored by: Google Summer of Code 2009
Approved by: re (kib)


# 8c8fff31 22-Jun-2009 Andrew Thompson <thompsa@FreeBSD.org>

Add files missed in r194674.

Add libusb 1.0 support which is compatible with the latest revision on
Sourceforge. Libusb 1.0 is a portable usb api released December 2008 and
supersedes the original libusb released 10 years ago, it supports isochronous
endpoints and asynchronous I/O. Many applications have already started using
the interfaces.

This has been developed as part of Google Summer of Code this year by Sylvestre
Gallon and has been cribbed early due to it being desirable in FreeBSD 8.0

Submitted by: Sylvestre Gallon
Sponsored by: Google Summer of Code 2009
Reviewed by: Hans Petter Selasky