libusb1 has been replaced with libusbx

This commit is contained in:
Hans de Goede 2012-05-23 21:23:05 +02:00
parent 671c062c1a
commit 82dc8c9186
9 changed files with 1 additions and 482 deletions

3
.gitignore vendored
View File

@ -1,3 +0,0 @@
libusb-1.0.8.tar.bz2
/libusb-1.0.9-0.1.tar.bz2
/libusb-1.0.9-rc1.tar.bz2

View File

@ -1,32 +0,0 @@
From 1cc5b4a9fb984e83681ae5c797fa6b22bc20f809 Mon Sep 17 00:00:00 2001
From: Ludovic Rousseau <ludovic.rousseau+github@gmail.com>
Date: Fri, 16 Sep 2011 18:07:56 +0200
Subject: [PATCH 01/40] 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.
---
libusb/sync.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libusb/sync.c b/libusb/sync.c
index d50413b..8eed47b 100644
--- a/libusb/sync.c
+++ b/libusb/sync.c
@@ -132,6 +132,9 @@ int API_EXPORTED libusb_control_transfer(libusb_device_handle *dev_handle,
case LIBUSB_TRANSFER_NO_DEVICE:
r = LIBUSB_ERROR_NO_DEVICE;
break;
+ case LIBUSB_TRANSFER_OVERFLOW:
+ r = LIBUSB_ERROR_OVERFLOW;
+ break;
default:
usbi_warn(HANDLE_CTX(dev_handle),
"unrecognised status code %d", transfer->status);
--
1.7.9.3

View File

@ -1,37 +0,0 @@
From 52508a86e26f0bc74b0a7a3b05ed08a29996b44c Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 20 Feb 2012 16:05:48 +0100
Subject: [PATCH 1/6] linux: Fix cancel_transfer return value when cancelling
a multi-urb transfer
If we fail to cancel the last urb of a multi-urb transfer because it
has already completed (errno == EINVAL on DISCARD_URB), then the entire
transfer has already completed, so returning NOT_FOUND is consistent with what
the documentation for libusb_cancel_transfer says.
But if we've successfully cancelled the last urb, and then another urb
fails with errno == EINVAL, this means that we've still cancelled the
transfer, as it has only *partially* completed.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
libusb/os/linux_usbfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
index 2b81189..099fc61 100644
--- a/libusb/os/linux_usbfs.c
+++ b/libusb/os/linux_usbfs.c
@@ -1466,7 +1466,8 @@ static int discard_urbs(struct usbi_transfer *itransfer, int first, int last_plu
if (EINVAL == errno) {
usbi_dbg("URB not found --> assuming ready to be reaped");
- ret = LIBUSB_ERROR_NOT_FOUND;
+ if (i == (last_plus_one - 1))
+ ret = LIBUSB_ERROR_NOT_FOUND;
} else if (ENODEV == errno) {
usbi_dbg("Device not found for URB --> assuming ready to be reaped");
ret = LIBUSB_ERROR_NO_DEVICE;
--
1.7.9.3

View File

@ -1,46 +0,0 @@
From e8c0b72bf8cc6d89c3546bbdbcc85b2c63086578 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 20 Feb 2012 16:12:19 +0100
Subject: [PATCH 2/6] Don't print errors when cancel_transfer fails with
NOT_FOUND
As stated in the documentation for libusb_cancel_transfer,
LIBUSB_ERROR_NOT_FOUND is an expected return value for
libusb_cancel_transfer (under certain circumstances) printing
an error each time this happens therefor is undesirable.
More so because under Linux IOCTL_USBFS_DISCARDURB sets errno
to EINVAL when the kernel could not find the urb in the kernels
urbs in flight list. Which means that the urb has already completed
at the host controller level, but it has not necessarily already
been reaped. IOW under Linux libusb_cancel_transfer may yield a
result of LIBUSB_ERROR_NOT_FOUND *before* the transfer's callback
has been called! So there is no way for an application to avoid
calling libusb_cancel_transfer on already completed transfers.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
libusb/io.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/libusb/io.c b/libusb/io.c
index bb6e275..9f46cf0 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -1351,8 +1351,11 @@ int API_EXPORTED libusb_cancel_transfer(struct libusb_transfer *transfer)
usbi_mutex_lock(&itransfer->lock);
r = usbi_backend->cancel_transfer(itransfer);
if (r < 0) {
- usbi_err(TRANSFER_CTX(transfer),
- "cancel transfer failed error %d", r);
+ if (r != LIBUSB_ERROR_NOT_FOUND)
+ usbi_err(TRANSFER_CTX(transfer),
+ "cancel transfer failed error %d", r);
+ else
+ usbi_dbg("cancel transfer failed error %d", r);
if (r == LIBUSB_ERROR_NO_DEVICE)
itransfer->flags |= USBI_TRANSFER_DEVICE_DISAPPEARED;
--
1.7.9.3

View File

@ -1,92 +0,0 @@
From 3b6ed16cd2f098dd3920853d20940b3560c20ece Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Fri, 24 Feb 2012 10:24:00 +0100
Subject: [PATCH 3/6] linux: Fix handling of urb status codes
During testing of my usbredir code I hit a case where EOVERFLOW was not handled
in handle_control_completion. Instead of just fixing this one case I've audited
(and fixed where necessary) all handle_foo_completion functions to know about
all errors documented in linux/Documentation/usb/error-codes.txt.
Note that for handle_iso_completion this patch actually removes the handling
of some codes, since these can never occur on an iso urb (they can only
occur on the iso packets included in the urb, see the next patch in this
series). Also in case an unknown status is encountered on an iso urb, this
patch actually sets the urb's status to ERROR, rather then leaving it at
completed.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
libusb/os/linux_usbfs.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
index 099fc61..36d37a4 100644
--- a/libusb/os/linux_usbfs.c
+++ b/libusb/os/linux_usbfs.c
@@ -1952,6 +1952,7 @@ static int handle_bulk_completion(struct usbi_transfer *itransfer,
case -ENOENT: /* cancelled */
case -ECONNRESET:
break;
+ case -ENODEV:
case -ESHUTDOWN:
usbi_dbg("device removed");
tpriv->reap_status = LIBUSB_TRANSFER_NO_DEVICE;
@@ -1970,6 +1971,8 @@ static int handle_bulk_completion(struct usbi_transfer *itransfer,
case -ETIME:
case -EPROTO:
case -EILSEQ:
+ case -ECOMM:
+ case -ENOSR:
usbi_dbg("low level error %d", urb->status);
tpriv->reap_action = ERROR;
goto cancel_remaining;
@@ -2081,19 +2084,16 @@ static int handle_iso_completion(struct usbi_transfer *itransfer,
case 0:
break;
case -ENOENT: /* cancelled */
+ case -ECONNRESET:
break;
case -ESHUTDOWN:
usbi_dbg("device removed");
status = LIBUSB_TRANSFER_NO_DEVICE;
break;
- case -ETIME:
- case -EPROTO:
- case -EILSEQ:
- usbi_dbg("low-level USB error %d", urb->status);
- break;
default:
usbi_warn(TRANSFER_CTX(transfer),
"unrecognised urb status %d", urb->status);
+ status = LIBUSB_TRANSFER_ERROR;
break;
}
@@ -2139,6 +2139,7 @@ static int handle_control_completion(struct usbi_transfer *itransfer,
case -ENOENT: /* cancelled */
status = LIBUSB_TRANSFER_CANCELLED;
break;
+ case -ENODEV:
case -ESHUTDOWN:
usbi_dbg("device removed");
status = LIBUSB_TRANSFER_NO_DEVICE;
@@ -2147,9 +2148,15 @@ static int handle_control_completion(struct usbi_transfer *itransfer,
usbi_dbg("unsupported control request");
status = LIBUSB_TRANSFER_STALL;
break;
+ case -EOVERFLOW:
+ usbi_dbg("control overflow error");
+ status = LIBUSB_TRANSFER_OVERFLOW;
+ break;
case -ETIME:
case -EPROTO:
case -EILSEQ:
+ case -ECOMM:
+ case -ENOSR:
usbi_dbg("low-level bus error occurred");
status = LIBUSB_TRANSFER_ERROR;
break;
--
1.7.9.3

View File

@ -1,68 +0,0 @@
From 4c3e7f9818c0d1d0462fde6f219da65fb102a434 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Fri, 24 Feb 2012 11:15:30 +0100
Subject: [PATCH 4/6] linux: Translate linux iso pkt status codes to libusb
transfer status codes
During testing of my usbredir code I hit a scenario where my libusb app
was seeing EXDEV as status in the transfer's iso_packet_desc
This happened because we don't translate linux negative errno errors
stored in iso pkts status to libusb transfer status codes at all! So this
patch adds translation for this.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
libusb/os/linux_usbfs.c | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
index 36d37a4..a7d8298 100644
--- a/libusb/os/linux_usbfs.c
+++ b/libusb/os/linux_usbfs.c
@@ -2053,7 +2053,41 @@ static int handle_iso_completion(struct usbi_transfer *itransfer,
struct usbfs_iso_packet_desc *urb_desc = &urb->iso_frame_desc[i];
struct libusb_iso_packet_descriptor *lib_desc =
&transfer->iso_packet_desc[tpriv->iso_packet_offset++];
- lib_desc->status = urb_desc->status;
+ lib_desc->status = LIBUSB_TRANSFER_COMPLETED;
+ switch (urb_desc->status) {
+ case 0:
+ break;
+ case -ENOENT: /* cancelled */
+ case -ECONNRESET:
+ break;
+ case -ENODEV:
+ case -ESHUTDOWN:
+ usbi_dbg("device removed");
+ lib_desc->status = LIBUSB_TRANSFER_NO_DEVICE;
+ break;
+ case -EPIPE:
+ usbi_dbg("detected endpoint stall");
+ lib_desc->status = LIBUSB_TRANSFER_STALL;
+ break;
+ case -EOVERFLOW:
+ usbi_dbg("overflow error");
+ lib_desc->status = LIBUSB_TRANSFER_OVERFLOW;
+ break;
+ case -ETIME:
+ case -EPROTO:
+ case -EILSEQ:
+ case -ECOMM:
+ case -ENOSR:
+ case -EXDEV:
+ usbi_dbg("low-level USB error %d", urb_desc->status);
+ lib_desc->status = LIBUSB_TRANSFER_ERROR;
+ break;
+ default:
+ usbi_warn(TRANSFER_CTX(transfer),
+ "unrecognised urb status %d", urb_desc->status);
+ lib_desc->status = LIBUSB_TRANSFER_ERROR;
+ break;
+ }
lib_desc->actual_length = urb_desc->actual_length;
}
--
1.7.9.3

1
dead.package Normal file
View File

@ -0,0 +1 @@
libusb1 has been replaced with libusbx

View File

@ -1,203 +0,0 @@
Summary: A library which allows userspace access to USB devices
Name: libusb1
Version: 1.0.9
Release: 0.6.rc1%{?dist}
# This is a git snapshot of what will hopefully soon become 1.0.9, but
# we need this now, to get things in place for:
# http://fedoraproject.org/wiki/Features/UsbNetworkRedirection
# To regenerate do:
# git clone git://git.libusb.org/libusb.git
# cd libusb
# git checkout 1.0.9-rc1
# ./autogen.sh
# make dist
# mv libusb-1.0.8.tar.bz2 libusb-1.0.9-rc1.tar.bz2
Source0: libusb-1.0.9-rc1.tar.bz2
#Source0: http://downloads.sourceforge.net/libusb/libusb-%{version}.tar.bz2
Patch1: 0001-Correctly-handle-LIBUSB_TRANSFER_OVERFLOW-in-libusb_.patch
Patch2: 0002-linux-Fix-cancel_transfer-return-value-when-cancelli.patch
Patch3: 0003-Don-t-print-errors-when-cancel_transfer-fails-with-N.patch
Patch4: 0004-linux-Fix-handling-of-urb-status-codes.patch
Patch5: 0005-linux-Translate-linux-iso-pkt-status-codes-to-libusb.patch
License: LGPLv2+
Group: System Environment/Libraries
URL: http://libusb.wiki.sourceforge.net/Libusb1.0
BuildRequires: doxygen
%description
This package provides a way for applications to access USB devices. Note that
this library is not compatible with the original libusb-0.1 series.
%package devel
Summary: Development files for libusb
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: %{name}-devel-doc = %{version}-%{release}
Requires: pkgconfig
%description devel
This package contains the header files and libraries needed to develop
applications that use libusb1.
%package devel-doc
Summary: Development files for libusb
Group: Development/Libraries
Requires: %{name}-devel = %{version}-%{release}
BuildArch: noarch
%description devel-doc
This package contains documentation needed to develop applications that
use libusb1.
%package static
Summary: Static development files for libusb
Group: Development/Libraries
Requires: %{name}-devel = %{version}-%{release}
%description static
This package contains static libraries to develop applications that use libusb1.
%prep
%setup -q -n libusb-1.0.8
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%build
%configure --libdir=/%{_lib}
make CFLAGS="$RPM_OPT_FLAGS"
pushd doc
make docs
popd
%install
make install DESTDIR=$RPM_BUILD_ROOT
rm -f $RPM_BUILD_ROOT/%{_lib}/*.la
# Our snapshot reports itself as 1.0.8, change the pkg-config file version to
# 1.0.9 so that configure checks by apps who need the new 1.0.9 succeed
sed -i 's/1\.0\.8/1.0.9/' %{buildroot}/%{_lib}/pkgconfig/libusb-1.0.pc
mkdir -p %{buildroot}%{_libdir}/pkgconfig
mv %{buildroot}/%{_lib}/pkgconfig/* %{buildroot}%{_libdir}/pkgconfig/
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(-,root,root)
%doc AUTHORS COPYING README NEWS ChangeLog
/%{_lib}/*.so.*
%files devel
%defattr(-,root,root)
%{_includedir}/*
/%{_lib}/*.so
%{_libdir}/pkgconfig/libusb-1.0.pc
%files devel-doc
%defattr(-,root,root)
%doc doc/html examples/*.c
%files static
%defattr(-,root,root)
/%{_lib}/*.a
%changelog
* Wed Mar 14 2012 Hans de Goede <hdegoede@redhat.com> - 1.0.9-0.6.rc1
- One more small error handling fix
* Wed Mar 14 2012 Hans de Goede <hdegoede@redhat.com> - 1.0.9-0.5.rc1
- Add some small error handling fixes
* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.9-0.4.rc1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
* Fri Sep 16 2011 Hans de Goede <hdegoede@redhat.com> - 1.0.9-0.3.rc1
- Update to upstream 1.0.9-rc1 release
* Thu Aug 11 2011 Hans de Goede <hdegoede@redhat.com> - 1.0.9-0.2.git212ca37c
- Report version in pkg-config file as 1.0.9
* Thu Jul 14 2011 Hans de Goede <hdegoede@redhat.com> - 1.0.9-0.1.git212ca37c
- Update to a git snapshot which should be pretty close to the final 1.0.9
- Many bugfixes
- Needed for: http://fedoraproject.org/wiki/Features/UsbNetworkRedirection
* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.8-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
* Wed Jan 26 2011 Jan Vcelak <jvcelak@redhat.com> 1.0.8-6
- package config file has to be in /usr/lib/pkgconfig
* Tue Jan 25 2011 Jan Vcelak <jvcelak@redhat.com> 1.0.8-5
- move libraries from /usr/lib to /lib (#519716)
* Sun Nov 07 2010 Dan Horák <dan[at]danny.cz> - 1.0.8-4
- drop the ExcludeArch as it's causing too many troubles
* Wed Sep 29 2010 jkeating - 1.0.8-3
- Rebuilt for gcc bug 634757
* Tue Sep 14 2010 Jan Vcelak <jvcelak@redhat.com> 1.0.8-2
- USB access error messages are now handled by standard logging mechanism
instead of printing to stderr (#628356)
* Mon May 17 2010 Jindrich Novy <jnovy@redhat.com> 1.0.8-1
- update to 1.0.8 (#592901)
* Fri Jan 22 2010 Jindrich Novy <jnovy@redhat.com> 1.0.6-2
- put all doxygen and other docs to separate noarch subpackage to avoid
multiarch conflicts (#507980)
* Wed Dec 02 2009 Jindrich Novy <jnovy@redhat.com> 1.0.6-1
- update to 1.0.6
* Mon Sep 28 2009 Jindrich Novy <jnovy@redhat.com> 1.0.3-1
- update to 1.0.3
* Sat Jul 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
* Mon Jun 15 2009 Jindrich Novy <jnovy@redhat.com> 1.0.2-1
- update to 1.0.2
* Wed May 13 2009 Jindrich Novy <jnovy@redhat.com> 1.0.1-1
- update to 1.0.1
* Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild
* Mon Dec 15 2008 - Bastien Nocera <bnocera@redhat.com> - 1.0.0-1
- Update to 1.0.0
* Fri Nov 21 2008 - Bastien Nocera <bnocera@redhat.com> - 0.9.4-1
- Update to 0.9.4
* Tue Sep 23 2008 Jindrich Novy <jnovy@redhat.com> 0.9.3-0.1
- update to 0.9.3
* Sun Jul 06 2008 - Bastien Nocera <bnocera@redhat.com> - 0.9.1
- Update to 0.9.1
* Mon May 26 2008 Jindrich Novy <jnovy@redhat.com> 0.9.0-0.4
- update to official beta
* Thu May 23 2008 Jindrich Novy <jnovy@redhat.com> 0.9.0-0.3.gitbef33bb
- update comment on how the tarball was created
- use abbreviated git hash within package name to avoid conflicts
- add to %%description that libusb1 is incompatible with libsub-0.1
* Thu May 22 2008 Jindrich Novy <jnovy@redhat.com> 0.9.0-0.2.gitbef33bb
- add info on how the snapshot tarball was created
* Wed May 21 2008 Jindrich Novy <jnovy@redhat.com> 0.9.0-0.1.gitbef33bb
- use proper version to denote it is a git snapshot
* Thu May 15 2008 Jindrich Novy <jnovy@redhat.com> 0.9.0-0.1
- initial packaging

View File

@ -1 +0,0 @@
389dd12f7da1411aac2524c5de35e2f5 libusb-1.0.9-rc1.tar.bz2