Mailinglist Archive: opensuse-commit (561 mails)
| < Previous | Next > |
commit libusb-1_0 for openSUSE:Factory
- From: root@xxxxxxxxxxxxxxx (h_root)
- Date: Mon, 28 Jun 2010 16:18:43 +0200
- Message-id: <20100628141843.7A59F20244@xxxxxxxxxxxxxxx>
Hello community,
here is the log from the commit of package libusb-1_0 for openSUSE:Factory
checked in at Mon Jun 28 16:18:43 CEST 2010.
--------
--- libusb-1_0/libusb-1_0.changes 2010-04-24 12:14:28.000000000 +0200
+++ /mounts/work_src_done/STABLE/libusb-1_0/libusb-1_0.changes 2010-06-21
12:42:11.000000000 +0200
@@ -1,0 +2,8 @@
+Mon Jun 21 12:00:40 CEST 2010 - opensuse@xxxxxxxxxxxxxxx
+
+- Updated to version 1.0.8:
+ * Bug fixes and documentation tweaks
+ * Add more interface class definitions
+- This release fixes a crash for kernel's with debug flag enabled
+
+-------------------------------------------------------------------
calling whatdependson for head-i586
Old:
----
libusb-1.0.6.tar.bz2
New:
----
libusb-1.0.8.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ libusb-1_0.spec ++++++
--- /var/tmp/diff_new_pack.f5v9fu/_old 2010-06-28 16:18:14.000000000 +0200
+++ /var/tmp/diff_new_pack.f5v9fu/_new 2010-06-28 16:18:14.000000000 +0200
@@ -1,5 +1,5 @@
#
-# spec file for package libusb-1_0 (Version 1.0.6)
+# spec file for package libusb-1_0 (Version 1.0.8)
#
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
@@ -20,12 +20,12 @@
Name: libusb-1_0
%define _name libusb
-Url: http://libusb.wiki.sourceforge.net/Libusb1.0
+Url: http://www.libusb.org/
License: LGPLv2.1+
Summary: USB Library
Group: System/Libraries
-Version: 1.0.6
-Release: 4
+Version: 1.0.8
+Release: 1
Source: %{_name}-%{version}.tar.bz2
Source2: baselibs.conf
BuildRoot: %{_tmppath}/%{name}-%{version}-build
++++++ libusb-1.0.6.tar.bz2 -> libusb-1.0.8.tar.bz2 ++++++
++++ 10019 lines of diff (skipped)
++++ retrying with extended exclude list
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/libusb-1.0.6/AUTHORS new/libusb-1.0.8/AUTHORS
--- old/libusb-1.0.6/AUTHORS 2009-11-15 13:16:57.000000000 +0100
+++ new/libusb-1.0.8/AUTHORS 2010-04-21 23:44:30.000000000 +0200
@@ -1,6 +1,6 @@
Copyright (C) 2007-2009 Daniel Drake <dsd@xxxxxxxxxx>
Copyright (c) 2001 Johannes Erdfelt <johannes@xxxxxxxxxxx>
-Copyright (C) 2008-2009 Nathan Hjelm <hjelmn@xxxxxxxxxxxxxxxxxxxxx>
+Copyright (C) 2008-2010 Nathan Hjelm <hjelmn@xxxxxxxxxxxxxxxxxxxxx>
Other contributors:
Alex Vatchenko
@@ -12,6 +12,7 @@
Felipe Balbi
Hans Ulrich Niedermann
Ludovic Rousseau
+Martin Koegler
Mikhail Gusarov
Rob Walker
Toby Peterson
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/libusb-1.0.6/ChangeLog new/libusb-1.0.8/ChangeLog
--- old/libusb-1.0.6/ChangeLog 2009-11-22 18:21:18.000000000 +0100
+++ new/libusb-1.0.8/ChangeLog 2010-05-05 00:02:23.000000000 +0200
@@ -1,3 +1,129 @@
+commit a04cbb0095a78aeed3f65aaf06c46069d0ac184a
+Author: Daniel Drake <dan@xxxxxxxxxxxxxxx>
+Date: Tue May 4 19:01:59 2010 -0300
+
+ v1.0.8 release
+
+commit 53b47299531974fa8901b74a163f3c8ebae4eec9
+Author: Daniel Drake <dan@xxxxxxxxxxxxxxx>
+Date: Thu Apr 22 18:12:51 2010 -0300
+
+ Linux: don't set SHORT_NOT_OK on bulk out URBs (#20
+
+ Setting this flag is illegal, and the behaviour we're looking for
+ is already in place for host-to-device transfers without this flag.
+
+commit 1519828b7ee1fce46d4c51fc097d52e01b8e0bb4
+Author: Daniel Drake <dan@xxxxxxxxxxxxxxx>
+Date: Tue Apr 20 20:14:09 2010 -0300
+
+ Linux: Handle failure to read active configuration during enumeration
+
+commit 45168627cc15aee3875192f34286110dbbd27095
+Author: Nathan Hjelm <hjelmn@xxxxxx>
+Date: Tue Apr 20 19:43:06 2010 -0300
+
+ Darwin: don't reuse cached descriptors during enumeration
+
+ Descriptor reuse was causing scans to return invalid information when
+ the device at a location has changed.
+
+commit 3af329db6dcbfb96d24867c757f9e125e5b7b0e5
+Author: Daniel Drake <dan@xxxxxxxxxxxxxxx>
+Date: Mon Apr 19 19:36:55 2010 -0300
+
+ v1.0.7 release
+
+commit ceb8cacd6d2a4189de0db2ee46d45217511c69be
+Author: Daniel Drake <dan@xxxxxxxxxxxxxxx>
+Date: Mon Apr 19 19:31:12 2010 -0300
+
+ Document that fd set contents are an internal implementation detail (#36)
+
+commit 9bea500b5747bdeba7c8251d45608558e71a1db5
+Author: Martin Koegler <mkoegler@xxxxxxxxxxxxxxxxx>
+Date: Mon Apr 19 19:22:46 2010 -0300
+
+ Linux: correct config descriptor endianness fix
+
+ The seek_to_next_config codepath deals with both sysfs and usbfs;
+ make sure we only convert values in the usbfs path.
+
+commit 02df59a309e813c50b8230de99e69fb4e1814279
+Author: Martin Koegler <mkoegler@xxxxxxxxxxxxxxxxx>
+Date: Mon Apr 5 17:11:32 2010 +0200
+
+ Linux: Fix endianness handling of usbfs config descriptors (#27)
+
+ driver/usb/core/devio.c function usbdev_read translate the follwing files
+ to CPU endianess:
+
+ le16_to_cpus(&temp_desc.bcdUSB);
+ le16_to_cpus(&temp_desc.idVendor);
+ le16_to_cpus(&temp_desc.idProduct);
+ le16_to_cpus(&temp_desc.bcdDevice);
+
+ All other data is passed without any change.
+
+ libusb/os/linux_usbfs.c calls usbi_parse_descriptor with host_endian=1
+ for config descriptors. According to the kernel code, they must be
+ processed with host_endian=0, as they are not translated by the kernel.
+
+ Signed-off-by: Martin Koegler <mkoegler@xxxxxxxxxxxxxxxxx>
+
+commit ec303b01a5d4e51c000a283853af65059fa62285
+Author: Nathan Hjelm <hjelmn@xxxxxxx>
+Date: Tue Mar 23 16:22:08 2010 -0600
+
+ Darwin: fix enumeration of devices with non-consecutive addresses (#23)
+
+commit cd809e2f7cee3874b7ae16b2c482a8b63a90e4a5
+Author: Bastien Nocera <hadess@xxxxxxxxxx>
+Date: Mon Mar 8 10:50:51 2010 +0000
+
+ Add more interface classes
+
+ As used in bluez.
+
+commit 1ce4aa67d849f5cad8a21072dc1c7b42158ce817
+Author: Nathan Hjelm <hjelmn@xxxxxxx>
+Date: Thu Mar 18 11:32:32 2010 -0600
+
+ Darwin: Cleanup async callback code, catch request timeouts
+
+commit 68af9f8d731f700267335941a8214d34ab518cc8
+Author: Nathan Hjelm <hjelmn@xxxxxxx>
+Date: Thu Mar 18 11:31:46 2010 -0600
+
+ Darwin: fix endianness of control setup packet
+
+ IOUSBLib expects the control request to be in host byte order.
+ Swap the request into host byte order.
+
+commit cfce4d127184f4e4f334976151a0f80594bb5e22
+Author: Nathan Hjelm <hjelmn@xxxxxxx>
+Date: Mon Feb 15 14:10:08 2010 -0600
+
+ Darwin: fix memory leak in process_device
+
+ Credit to Mike Colagrosso for finding this bug.
+
+commit 161893cfbefefe315f657677705abe090fc526f2
+Author: Nathan Hjelm <hjelmn@xxxxxxx>
+Date: Mon Feb 15 14:09:19 2010 -0600
+
+ Darwin: use logging functions
+
+ Use usbi_warn, usbi_err, and usbi_info instead of _usbi_log.
+
+commit 2a72f38548208044dc3aa62681419d006c35732d
+Author: Nathan Hjelm <hjelmn@xxxxxxx>
+Date: Mon Feb 15 14:07:44 2010 -0600
+
+ Darwin: support multiple calls to libusb_init
+
+ Credit to Orin Eman for finding this bug.
+
commit a4186794d87124503db2f5f51f51ce90bb95daa7
Author: Daniel Drake <dan@xxxxxxxxxxxxxxx>
Date: Sun Nov 22 17:20:53 2009 +0000
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/libusb-1.0.6/config.h.in new/libusb-1.0.8/config.h.in
--- old/libusb-1.0.6/config.h.in 2009-11-22 18:21:18.000000000 +0100
+++ new/libusb-1.0.8/config.h.in 2010-05-05 00:02:23.000000000 +0200
@@ -70,6 +70,9 @@
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
/* Define to the version of this package. */
#undef PACKAGE_VERSION
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/libusb-1.0.6/configure.ac new/libusb-1.0.8/configure.ac
--- old/libusb-1.0.6/configure.ac 2009-11-22 18:18:23.000000000 +0100
+++ new/libusb-1.0.8/configure.ac 2010-05-05 00:01:36.000000000 +0200
@@ -1,4 +1,4 @@
-AC_INIT([libusb], [1.0.6])
+AC_INIT([libusb], [1.0.8])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([libusb/core.c])
AC_CONFIG_MACRO_DIR([m4])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/libusb-1.0.6/libusb/io.c new/libusb-1.0.8/libusb/io.c
--- old/libusb-1.0.6/libusb/io.c 2009-11-21 18:02:52.000000000 +0100
+++ new/libusb-1.0.8/libusb/io.c 2010-04-21 23:44:30.000000000 +0200
@@ -600,6 +600,13 @@
* these moments occur. This means that you need to adjust your
* poll()/select() timeout accordingly.
*
+ * libusb provides you with a set of file descriptors to poll and expects you
+ * to poll all of them, treating them as a single entity. The meaning of each
+ * file descriptor in the set is an internal implementation detail,
+ * platform-dependent and may vary from release to release. Don't try and
+ * interpret the meaning of the file descriptors, just do as libusb indicates,
+ * polling all of them at once.
+ *
* In pseudo-code, you want something that looks like:
\code
// initialise libusb
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/libusb-1.0.6/libusb/libusb.h new/libusb-1.0.8/libusb/libusb.h
--- old/libusb-1.0.6/libusb/libusb.h 2009-11-22 18:17:46.000000000 +0100
+++ new/libusb-1.0.8/libusb/libusb.h 2010-04-21 23:44:30.000000000 +0200
@@ -95,6 +95,12 @@
/** Data class */
LIBUSB_CLASS_DATA = 10,
+ /** Wireless class */
+ LIBUSB_CLASS_WIRELESS = 0xe0,
+
+ /** Application class */
+ LIBUSB_CLASS_APPLICATION = 0xfe,
+
/** Class is vendor-specific */
LIBUSB_CLASS_VENDOR_SPEC = 0xff
};
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/libusb-1.0.6/libusb/os/darwin_usb.c new/libusb-1.0.8/libusb/os/darwin_usb.c
--- old/libusb-1.0.6/libusb/os/darwin_usb.c 2009-11-21 18:10:21.000000000
+0100
+++ new/libusb-1.0.8/libusb/os/darwin_usb.c 2010-04-21 23:44:30.000000000
+0200
@@ -1,6 +1,6 @@
/*
* darwin backend for libusb 1.0
- * Copyright (C) 2008-2009 Nathan Hjelm <hjelmn@xxxxxxxxxxxxxxxxxxxxx>
+ * Copyright (C) 2008-2010 Nathan Hjelm <hjelmn@xxxxxxxxxxxxxxxxxxxxx>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -44,6 +44,7 @@
static mach_port_t libusb_darwin_mp = 0; /* master port */
static CFRunLoopRef libusb_darwin_acfl = NULL; /* async cf loop */
+static int initCount = 0;
/* async event thread */
static pthread_t libusb_darwin_at;
@@ -52,9 +53,6 @@
static int darwin_claim_interface(struct libusb_device_handle *dev_handle, int
iface);
static int darwin_release_interface(struct libusb_device_handle *dev_handle,
int iface);
static int darwin_reset_device(struct libusb_device_handle *dev_handle);
-static void darwin_bulk_callback (struct usbi_transfer *itransfer,
kern_return_t result, UInt32 io_size);
-static void darwin_isoc_callback (struct usbi_transfer *itransfer,
kern_return_t result);
-static void darwin_control_callback (struct usbi_transfer *itransfer,
kern_return_t result, UInt32 io_size);
static void darwin_async_io_callback (void *refcon, IOReturn result, void
*arg0);
static const char *darwin_error_str (int result) {
@@ -83,6 +81,8 @@
return "device not responding";
case kIOReturnOverrun:
return "data overrun";
+ case kIOReturnCannotWire:
+ return "physical memory can not be wired down";
default:
return "unknown error";
}
@@ -121,7 +121,7 @@
int8_t i, iface;
- _usbi_log (HANDLE_CTX(dev_handle), LOG_LEVEL_INFO, "converting ep address
0x%02x to pipeRef and interface", ep);
+ usbi_info (HANDLE_CTX(dev_handle), "converting ep address 0x%02x to pipeRef
and interface", ep);
for (iface = 0 ; iface < USB_MAXINTERFACES ; iface++) {
cInterface = &priv->interfaces[iface];
@@ -131,7 +131,7 @@
if (cInterface->endpoint_addrs[i] == ep) {
*pipep = i + 1;
*ifcp = iface;
- _usbi_log (HANDLE_CTX(dev_handle), LOG_LEVEL_INFO, "pipe %d on
interface %d matches", *pipep, *ifcp);
+ usbi_info (HANDLE_CTX(dev_handle), "pipe %d on interface %d matches",
*pipep, *ifcp);
return 0;
}
}
@@ -139,7 +139,7 @@
}
/* No pipe found with the correct endpoint address */
- _usbi_log (HANDLE_CTX(dev_handle), LOG_LEVEL_WARNING, "no pipeRef found with
endpoint address 0x%02x.", ep);
+ usbi_warn (HANDLE_CTX(dev_handle), "no pipeRef found with endpoint address
0x%02x.", ep);
return -1;
}
@@ -155,18 +155,22 @@
long result;
SInt32 score;
- if (!IOIteratorIsValid (deviceIterator) || !(usbDevice =
IOIteratorNext(deviceIterator)))
+ if (!IOIteratorIsValid (deviceIterator))
return NULL;
-
- result = IOCreatePlugInInterfaceForService(usbDevice,
kIOUSBDeviceUserClientTypeID,
- kIOCFPlugInInterfaceID,
&plugInInterface,
- &score);
-
- if (result || !plugInInterface) {
+
+
+ while ((usbDevice = IOIteratorNext(deviceIterator))) {
+ result = IOCreatePlugInInterfaceForService(usbDevice,
kIOUSBDeviceUserClientTypeID,
+ kIOCFPlugInInterfaceID,
&plugInInterface,
+ &score);
+ if (kIOReturnSuccess == result && plugInInterface)
+ break;
+
usbi_dbg ("libusb/darwin.c usb_get_next_device: could not set up plugin
for service: %s\n", darwin_error_str (result));
+ }
+ if (!usbDevice)
return NULL;
- }
(void)IOObjectRelease(usbDevice);
(void)(*plugInInterface)->QueryInterface(plugInInterface,
CFUUIDGetUUIDBytes(DeviceInterfaceID),
@@ -218,7 +222,7 @@
CFTypeRef locationCF;
UInt32 message;
- _usbi_log (ctx, LOG_LEVEL_INFO, "a device has been detached");
+ usbi_info (ctx, "a device has been detached");
while ((device = IOIteratorNext (rem_devices)) != 0) {
/* get the location from the i/o registry */
@@ -261,7 +265,7 @@
io_notification_port_t libusb_notification_port;
io_iterator_t libusb_rem_device_iterator;
- _usbi_log (ctx, LOG_LEVEL_INFO, "creating hotplug event source");
+ usbi_info (ctx, "creating hotplug event source");
CFRetain (CFRunLoopGetCurrent ());
@@ -277,7 +281,7 @@
(void *)ctx,
&libusb_rem_device_iterator);
if (kresult != kIOReturnSuccess) {
- _usbi_log (ctx, LOG_LEVEL_ERROR, "could not add hotplug event source: %s",
darwin_error_str (kresult));
+ usbi_err (ctx, "could not add hotplug event source: %s", darwin_error_str
(kresult));
pthread_exit ((void *)kresult);
}
@@ -288,12 +292,12 @@
/* let the main thread know about the async runloop */
libusb_darwin_acfl = CFRunLoopGetCurrent ();
- _usbi_log (ctx, LOG_LEVEL_INFO, "libopenusb/darwin.c event_thread_main:
thread ready to receive events");
+ usbi_info (ctx, "libopenusb/darwin.c event_thread_main: thread ready to
receive events");
/* run the runloop */
CFRunLoopRun();
- _usbi_log (ctx, LOG_LEVEL_INFO, "libopenusb/darwin.c event_thread_main:
thread exiting");
+ usbi_info (ctx, "libopenusb/darwin.c event_thread_main: thread exiting");
/* delete notification port */
CFRunLoopSourceInvalidate (libusb_notification_cfsource);
@@ -309,33 +313,37 @@
static int darwin_init(struct libusb_context *ctx) {
IOReturn kresult;
- /* Create the master port for talking to IOKit */
- if (!libusb_darwin_mp) {
- kresult = IOMasterPort (MACH_PORT_NULL, &libusb_darwin_mp);
+ if (!(initCount++)) {
+ /* Create the master port for talking to IOKit */
+ if (!libusb_darwin_mp) {
+ kresult = IOMasterPort (MACH_PORT_NULL, &libusb_darwin_mp);
- if (kresult != kIOReturnSuccess || !libusb_darwin_mp)
- return darwin_to_libusb (kresult);
- }
+ if (kresult != kIOReturnSuccess || !libusb_darwin_mp)
+ return darwin_to_libusb (kresult);
+ }
- pthread_create (&libusb_darwin_at, NULL, event_thread_main, (void *)ctx);
+ pthread_create (&libusb_darwin_at, NULL, event_thread_main, (void *)ctx);
- while (!libusb_darwin_acfl)
- usleep (10);
+ while (!libusb_darwin_acfl)
+ usleep (10);
+ }
return 0;
}
static void darwin_exit (void) {
- void *ret;
+ if (!(--initCount)) {
+ void *ret;
- /* stop the async runloop */
- CFRunLoopStop (libusb_darwin_acfl);
- pthread_join (libusb_darwin_at, &ret);
+ /* stop the async runloop */
+ CFRunLoopStop (libusb_darwin_acfl);
+ pthread_join (libusb_darwin_at, &ret);
- if (libusb_darwin_mp)
- mach_port_deallocate(mach_task_self(), libusb_darwin_mp);
+ if (libusb_darwin_mp)
+ mach_port_deallocate(mach_task_self(), libusb_darwin_mp);
- libusb_darwin_mp = 0;
+ libusb_darwin_mp = 0;
+ }
}
static int darwin_get_device_descriptor(struct libusb_device *dev, unsigned
char *buffer, int *host_endian) {
@@ -400,7 +408,7 @@
if (!priv->device) {
kresult = darwin_get_device (priv->location, &device);
if (kresult || !device) {
- _usbi_log (DEVICE_CTX (dev), LOG_LEVEL_ERROR, "could not find device:
%s", darwin_error_str (kresult));
+ usbi_err (DEVICE_CTX (dev), "could not find device: %s",
darwin_error_str (kresult));
return darwin_to_libusb (kresult);
}
@@ -434,14 +442,21 @@
UInt16 address, idVendor, idProduct;
UInt8 bDeviceClass, bDeviceSubClass;
IOUSBDevRequest req;
- int ret;
+ int ret = 0, need_unref = 0;
+
+ do {
+ dev = usbi_get_device_by_session_id(ctx, locationID);
+ if (!dev) {
+ usbi_info (ctx, "allocating new device for location 0x%08x", locationID);
+ dev = usbi_alloc_device(ctx, locationID);
+ need_unref = 1;
+ } else
+ usbi_info (ctx, "using existing device for location 0x%08x", locationID);
- dev = usbi_get_device_by_session_id(ctx, locationID);
- if (!dev) {
- _usbi_log (ctx, LOG_LEVEL_INFO, "allocating new device for location
0x%08x", locationID);
- dev = usbi_alloc_device(ctx, locationID);
- if (!dev)
- return LIBUSB_ERROR_NO_MEM;
+ if (!dev) {
+ ret = LIBUSB_ERROR_NO_MEM;
+ break;
+ }
priv = (struct darwin_device_priv *)dev->os_priv;
@@ -462,7 +477,7 @@
/**** retrieve device descriptors ****/
/* device must be open for DeviceRequest */
(*device)->USBDeviceOpen(device);
-
+
ret = (*(device))->DeviceRequest (device, &req);
if (ret != kIOReturnSuccess) {
int try_unsuspend = 1;
@@ -490,19 +505,20 @@
(*device)->USBDeviceClose (device);
if (ret != kIOReturnSuccess) {
- _usbi_log (ctx, LOG_LEVEL_WARNING, "could not retrieve device
descriptor: %s. skipping device", darwin_error_str (ret));
- libusb_unref_device(dev);
- return -1;
+ usbi_warn (ctx, "could not retrieve device descriptor: %s. skipping
device", darwin_error_str (ret));
+ ret = -1;
+ break;
}
+
/**** end: retrieve device descriptors ****/
/* catch buggy hubs (which appear to be virtual). Apple's own USB prober
has problems with these devices. */
if (libusb_le16_to_cpu (priv->dev_descriptor.idProduct) != idProduct) {
/* not a valid device */
- _usbi_log (ctx, LOG_LEVEL_WARNING, "idProduct from iokit (%04x) does not
match idProduct in descriptor (%04x). skipping device",
+ usbi_warn (ctx, "idProduct from iokit (%04x) does not match idProduct in
descriptor (%04x). skipping device",
idProduct, libusb_le16_to_cpu
(priv->dev_descriptor.idProduct));
- libusb_unref_device(dev);
- return -1;
+ ret = -1;
+ break;
}
dev->bus_number = locationID >> 24;
@@ -512,28 +528,26 @@
priv->location = locationID;
snprintf(priv->sys_path, 20, "%03i-%04x-%04x-%02x-%02x", address,
idVendor, idProduct, bDeviceClass, bDeviceSubClass);
- ret = usbi_sanitize_device(dev);
+ ret = usbi_sanitize_device (dev);
+ if (ret < 0)
+ break;
- if (ret < 0) {
- libusb_unref_device(dev);
- return -1;
+ /* append the device to the list of discovered devices */
+ discdevs = discovered_devs_append(*_discdevs, dev);
+ if (!discdevs) {
+ ret = LIBUSB_ERROR_NO_MEM;
+ break;
}
- } else {
- priv = (struct darwin_device_priv *)dev->os_priv;
-
- _usbi_log (ctx, LOG_LEVEL_INFO, "using existing device for location
0x%08x", locationID);
- }
-
- /* append the device to the list of discovered devices */
- discdevs = discovered_devs_append(*_discdevs, dev);
- if (!discdevs)
- return LIBUSB_ERROR_NO_MEM;
- *_discdevs = discdevs;
-
- _usbi_log (ctx, LOG_LEVEL_INFO, "found device with address %d at %s",
dev->device_address, priv->sys_path);
+ *_discdevs = discdevs;
- return 0;
+ usbi_info (ctx, "found device with address %d at %s", dev->device_address,
priv->sys_path);
+ } while (0);
+
+ if (need_unref)
+ libusb_unref_device(dev);
+
+ return ret;
}
static int darwin_get_device_list(struct libusb_context *ctx, struct
discovered_devs **_discdevs) {
@@ -569,7 +583,7 @@
if (0 == dpriv->open_count) {
kresult = darwin_get_device (dpriv->location, &darwin_device);
if (kresult) {
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "could not find
device: %s", darwin_error_str (kresult));
+ usbi_err (HANDLE_CTX (dev_handle), "could not find device: %s",
darwin_error_str (kresult));
return darwin_to_libusb (kresult);
}
@@ -579,7 +593,7 @@
kresult = (*(dpriv->device))->USBDeviceOpenSeize (dpriv->device);
if (kresult != kIOReturnSuccess) {
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "USBDeviceOpen:
%s", darwin_error_str(kresult));
+ usbi_err (HANDLE_CTX (dev_handle), "USBDeviceOpen: %s",
darwin_error_str(kresult));
switch (kresult) {
case kIOReturnExclusiveAccess:
@@ -616,7 +630,7 @@
usbi_add_pollfd(HANDLE_CTX(dev_handle), priv->fds[0], POLLIN);
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_INFO, "device open for
access");
+ usbi_info (HANDLE_CTX (dev_handle), "device open for access");
return 0;
}
@@ -629,7 +643,7 @@
if (dpriv->open_count == 0) {
/* something is probably very wrong if this is the case */
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "Close called on a
device that was not open!\n");
+ usbi_err (HANDLE_CTX (dev_handle), "Close called on a device that was not
open!\n");
return;
}
@@ -653,7 +667,7 @@
if (kresult) {
/* Log the fact that we had a problem closing the file, however failing
a
* close isn't really an error, so return success anyway */
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "USBDeviceClose:
%s", darwin_error_str(kresult));
+ usbi_err (HANDLE_CTX (dev_handle), "USBDeviceClose: %s",
darwin_error_str(kresult));
}
}
@@ -661,7 +675,7 @@
if (kresult) {
/* Log the fact that we had a problem closing the file, however failing a
* close isn't really an error, so return success anyway */
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "Release: %s",
darwin_error_str(kresult));
+ usbi_err (HANDLE_CTX (dev_handle), "Release: %s",
darwin_error_str(kresult));
}
dpriv->device = NULL;
@@ -752,12 +766,12 @@
u_int16_t dont_care2;
int i;
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_INFO, "building table of
endpoints.");
+ usbi_info (HANDLE_CTX (dev_handle), "building table of endpoints.");
/* retrieve the total number of endpoints on this interface */
kresult = (*(cInterface->interface))->GetNumEndpoints(cInterface->interface,
&numep);
if (kresult) {
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "can't get number of
endpoints for interface: %s", darwin_error_str(kresult));
+ usbi_err (HANDLE_CTX (dev_handle), "can't get number of endpoints for
interface: %s", darwin_error_str(kresult));
return darwin_to_libusb (kresult);
}
@@ -767,12 +781,12 @@
&dont_care2,
&dont_care3);
if (kresult != kIOReturnSuccess) {
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "error getting pipe
information for pipe %d: %s", i, darwin_error_str(kresult));
+ usbi_err (HANDLE_CTX (dev_handle), "error getting pipe information for
pipe %d: %s", i, darwin_error_str(kresult));
return darwin_to_libusb (kresult);
}
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_INFO, "interface: %i pipe
%i: dir: %i number: %i", iface, i, direction, number);
+ usbi_info (HANDLE_CTX (dev_handle), "interface: %i pipe %i: dir: %i
number: %i", iface, i, direction, number);
cInterface->endpoint_addrs[i - 1] = ((direction << 7 &
LIBUSB_ENDPOINT_DIR_MASK) | (number & LIBUSB_ENDPOINT_ADDRESS_MASK));
}
@@ -806,50 +820,50 @@
be configured. Otherwise, we need to do it ourselves, or there
will be no interfaces for the device. */
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_INFO, "no interface found;
selecting configuration" );
+ usbi_info (HANDLE_CTX (dev_handle), "no interface found; selecting
configuration" );
kresult = (*(dpriv->device))->GetNumberOfConfigurations (dpriv->device,
&nConfig);
if (kresult != kIOReturnSuccess) {
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR,
"GetNumberOfConfigurations: %s", darwin_error_str(kresult));
+ usbi_err (HANDLE_CTX (dev_handle), "GetNumberOfConfigurations: %s",
darwin_error_str(kresult));
return darwin_to_libusb(kresult);
}
if (nConfig < 1) {
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR,
"GetNumberOfConfigurations: no configurations");
+ usbi_err (HANDLE_CTX (dev_handle), "GetNumberOfConfigurations: no
configurations");
return LIBUSB_ERROR_OTHER;
}
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_INFO, "device has %d
configuration%s. using the first",
+ usbi_info (HANDLE_CTX (dev_handle), "device has %d configuration%s. using
the first",
(int)nConfig, (nConfig > 1 ? "s" : "") );
/* Always use the first configuration */
kresult = (*(dpriv->device))->GetConfigurationDescriptorPtr
(dpriv->device, 0, &configDesc);
if (kresult != kIOReturnSuccess) {
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR,
"GetConfigurationDescriptorPtr: %s",
+ usbi_err (HANDLE_CTX (dev_handle), "GetConfigurationDescriptorPtr: %s",
darwin_error_str(kresult));
new_config = 1;
} else
new_config = configDesc->bConfigurationValue;
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_INFO, "new configuration
value is %d", new_config);
+ usbi_info (HANDLE_CTX (dev_handle), "new configuration value is %d",
new_config);
/* set the configuration */
kresult = darwin_set_configuration (dev_handle, new_config);
if (kresult != LIBUSB_SUCCESS) {
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "could not set
configuration");
+ usbi_err (HANDLE_CTX (dev_handle), "could not set configuration");
return kresult;
}
kresult = darwin_get_interface (dpriv->device, iface, &usbInterface);
if (kresult) {
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR,
"darwin_get_interface: %s", darwin_error_str(kresult));
+ usbi_err (HANDLE_CTX (dev_handle), "darwin_get_interface: %s",
darwin_error_str(kresult));
return darwin_to_libusb (kresult);
}
}
if (!usbInterface) {
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "interface not
found");
+ usbi_err (HANDLE_CTX (dev_handle), "interface not found");
return LIBUSB_ERROR_NOT_FOUND;
}
@@ -857,12 +871,12 @@
kresult = IOCreatePlugInInterfaceForService (usbInterface,
kIOUSBInterfaceUserClientTypeID,
kIOCFPlugInInterfaceID,
&plugInInterface, &score);
if (kresult) {
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR,
"IOCreatePlugInInterfaceForService: %s", darwin_error_str(kresult));
+ usbi_err (HANDLE_CTX (dev_handle), "IOCreatePlugInInterfaceForService:
%s", darwin_error_str(kresult));
return darwin_to_libusb (kresult);
}
if (!plugInInterface) {
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "plugin interface not
found");
+ usbi_err (HANDLE_CTX (dev_handle), "plugin interface not found");
return LIBUSB_ERROR_NOT_FOUND;
}
@@ -874,7 +888,7 @@
CFUUIDGetUUIDBytes(kIOUSBInterfaceInterfaceID),
(LPVOID)&cInterface->interface);
if (kresult || !cInterface->interface) {
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "QueryInterface: %s",
darwin_error_str(kresult));
+ usbi_err (HANDLE_CTX (dev_handle), "QueryInterface: %s",
darwin_error_str(kresult));
return darwin_to_libusb (kresult);
}
@@ -884,7 +898,7 @@
/* claim the interface */
kresult =
(*(cInterface->interface))->USBInterfaceOpen(cInterface->interface);
if (kresult) {
- _usbi_log(HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "USBInterfaceOpen:
%s", darwin_error_str(kresult));
+ usbi_err (HANDLE_CTX (dev_handle), "USBInterfaceOpen: %s",
darwin_error_str(kresult));
return darwin_to_libusb (kresult);
}
@@ -893,7 +907,7 @@
if (kresult) {
/* this should not happen */
darwin_release_interface (dev_handle, iface);
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "could not build
endpoint table");
+ usbi_err (HANDLE_CTX (dev_handle), "could not build endpoint table");
return kresult;
}
@@ -902,7 +916,7 @@
/* create async event source */
kresult = (*(cInterface->interface))->CreateInterfaceAsyncEventSource
(cInterface->interface, &cInterface->cfSource);
if (kresult != kIOReturnSuccess) {
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "could not create
async event source");
+ usbi_err (HANDLE_CTX (dev_handle), "could not create async event source");
/* can't continue without an async event source */
(void)darwin_release_interface (dev_handle, iface);
@@ -913,7 +927,7 @@
/* add the cfSource to the async thread's run loop */
CFRunLoopAddSource(libusb_darwin_acfl, cInterface->cfSource,
kCFRunLoopDefaultMode);
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_INFO, "interface opened");
+ usbi_info (HANDLE_CTX (dev_handle), "interface opened");
return 0;
}
@@ -940,11 +954,11 @@
kresult =
(*(cInterface->interface))->USBInterfaceClose(cInterface->interface);
if (kresult)
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "USBInterfaceClose:
%s", darwin_error_str(kresult));
+ usbi_err (HANDLE_CTX (dev_handle), "USBInterfaceClose: %s",
darwin_error_str(kresult));
kresult = (*(cInterface->interface))->Release(cInterface->interface);
if (kresult != kIOReturnSuccess)
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "Release: %s",
darwin_error_str(kresult));
+ usbi_err (HANDLE_CTX (dev_handle), "Release: %s",
darwin_error_str(kresult));
cInterface->interface = IO_OBJECT_NULL;
@@ -970,7 +984,7 @@
if (kresult) {
/* this should not happen */
darwin_release_interface (dev_handle, iface);
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "could not build
endpoint table");
+ usbi_err (HANDLE_CTX (dev_handle), "could not build endpoint table");
return kresult;
}
@@ -987,7 +1001,7 @@
/* determine the interface/endpoint to use */
if (ep_to_pipeRef (dev_handle, endpoint, &pipeRef, &iface) != 0) {
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "endpoint not found
on any open interface");
+ usbi_err (HANDLE_CTX (dev_handle), "endpoint not found on any open
interface");
return LIBUSB_ERROR_NOT_FOUND;
}
@@ -1001,7 +1015,7 @@
kresult =
(*(cInterface->interface))->ClearPipeStallBothEnds(cInterface->interface,
pipeRef);
#endif
if (kresult)
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "ClearPipeStall: %s",
darwin_error_str (kresult));
+ usbi_err (HANDLE_CTX (dev_handle), "ClearPipeStall: %s", darwin_error_str
(kresult));
return darwin_to_libusb (kresult);
}
@@ -1012,7 +1026,7 @@
kresult = (*(dpriv->device))->ResetDevice (dpriv->device);
if (kresult)
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR, "ResetDevice: %s",
darwin_error_str (kresult));
+ usbi_err (HANDLE_CTX (dev_handle), "ResetDevice: %s", darwin_error_str
(kresult));
return darwin_to_libusb (kresult);
}
@@ -1025,7 +1039,7 @@
kresult = darwin_get_interface (dpriv->device, interface, &usbInterface);
if (kresult) {
- _usbi_log (HANDLE_CTX (dev_handle), LOG_LEVEL_ERROR,
"darwin_get_interface: %s", darwin_error_str(kresult));
+ usbi_err (HANDLE_CTX (dev_handle), "darwin_get_interface: %s",
darwin_error_str(kresult));
return darwin_to_libusb (kresult);
}
@@ -1072,7 +1086,7 @@
is_read = transfer->endpoint & LIBUSB_ENDPOINT_IN;
if (ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef,
&iface) != 0) {
- _usbi_log (TRANSFER_CTX (transfer), LOG_LEVEL_ERROR, "endpoint not found
on any open interface");
+ usbi_err (TRANSFER_CTX (transfer), "endpoint not found on any open
interface");
return LIBUSB_ERROR_NOT_FOUND;
}
@@ -1103,8 +1117,8 @@
}
if (ret)
- _usbi_log (TRANSFER_CTX (transfer), LOG_LEVEL_ERROR, "bulk transfer failed
(dir = %s): %s", is_read ? "In" : "Out",
- darwin_error_str(ret));
+ usbi_err (TRANSFER_CTX (transfer), "bulk transfer failed (dir = %s): %s
(code = 0x%08x)", is_read ? "In" : "Out",
+ darwin_error_str(ret), ret);
return darwin_to_libusb (ret);
}
@@ -1137,7 +1151,7 @@
/* determine the interface/endpoint to use */
if (ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef,
&iface) != 0) {
- _usbi_log (TRANSFER_CTX (transfer), LOG_LEVEL_ERROR, "endpoint not found
on any open interface");
+ usbi_err (TRANSFER_CTX (transfer), "endpoint not found on any open
interface");
return LIBUSB_ERROR_NOT_FOUND;
}
@@ -1147,7 +1161,7 @@
/* Last but not least we need the bus frame number */
kresult =
(*(cInterface->interface))->GetBusFrameNumber(cInterface->interface, &frame,
&atTime);
if (kresult) {
- _usbi_log (TRANSFER_CTX (transfer), LOG_LEVEL_ERROR, "failed to get bus
frame number: %d", kresult);
+ usbi_err (TRANSFER_CTX (transfer), "failed to get bus frame number: %d",
kresult);
free(tpriv->isoc_framelist);
tpriv->isoc_framelist = NULL;
@@ -1168,7 +1182,7 @@
itransfer);
if (kresult != kIOReturnSuccess) {
- _usbi_log (TRANSFER_CTX (transfer), LOG_LEVEL_ERROR, "isochronous transfer
failed (dir: %s): %s", is_read ? "In" : "Out",
+ usbi_err (TRANSFER_CTX (transfer), "isochronous transfer failed (dir: %s):
%s", is_read ? "In" : "Out",
darwin_error_str(kresult));
free (tpriv->isoc_framelist);
tpriv->isoc_framelist = NULL;
@@ -1190,10 +1204,10 @@
/* IOUSBDeviceInterface expects the request in cpu endianess */
tpriv->req.bmRequestType = setup->bmRequestType;
tpriv->req.bRequest = setup->bRequest;
- /* these values should already be in bus order */
- tpriv->req.wValue = setup->wValue;
- tpriv->req.wIndex = setup->wIndex;
- tpriv->req.wLength = setup->wLength;
+ /* these values should be in bus order from libusb_fill_control_setup */
+ tpriv->req.wValue = OSSwapLittleToHostInt16 (setup->wValue);
+ tpriv->req.wIndex = OSSwapLittleToHostInt16 (setup->wIndex);
+ tpriv->req.wLength = OSSwapLittleToHostInt16 (setup->wLength);
/* data is stored after the libusb control block */
tpriv->req.pData = transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE;
tpriv->req.completionTimeout = transfer->timeout;
@@ -1203,7 +1217,7 @@
kresult = (*(dpriv->device))->DeviceRequestAsyncTO(dpriv->device,
&(tpriv->req), darwin_async_io_callback, itransfer);
if (kresult != kIOReturnSuccess)
- _usbi_log (TRANSFER_CTX (transfer), LOG_LEVEL_ERROR, "control request
failed: %s", darwin_error_str(kresult));
+ usbi_err (TRANSFER_CTX (transfer), "control request failed: %s",
darwin_error_str(kresult));
return darwin_to_libusb (kresult);
}
@@ -1220,7 +1234,7 @@
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
return submit_iso_transfer(itransfer);
default:
- _usbi_log (TRANSFER_CTX(transfer), LOG_LEVEL_ERROR, "unknown endpoint type
%d", transfer->type);
+ usbi_err (TRANSFER_CTX(transfer), "unknown endpoint type %d",
transfer->type);
return LIBUSB_ERROR_INVALID_PARAM;
}
}
@@ -1230,7 +1244,7 @@
struct darwin_device_priv *dpriv = (struct darwin_device_priv
*)transfer->dev_handle->dev->os_priv;
IOReturn kresult;
- _usbi_log (ITRANSFER_CTX (itransfer), LOG_LEVEL_INFO, "WARNING: aborting all
transactions control pipe");
+ usbi_info (ITRANSFER_CTX (itransfer), "WARNING: aborting all transactions
control pipe");
kresult = (*(dpriv->device))->USBDeviceAbortPipeZero (dpriv->device);
@@ -1245,19 +1259,19 @@
IOReturn kresult;
if (ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef,
&iface) != 0) {
- _usbi_log (TRANSFER_CTX (transfer), LOG_LEVEL_ERROR, "endpoint not found
on any open interface");
+ usbi_err (TRANSFER_CTX (transfer), "endpoint not found on any open
interface");
return LIBUSB_ERROR_NOT_FOUND;
}
cInterface = &priv->interfaces[iface];
- _usbi_log (ITRANSFER_CTX (itransfer), LOG_LEVEL_INFO, "WARNING: aborting all
transactions on interface %d pipe %d", iface, pipeRef);
+ usbi_info (ITRANSFER_CTX (itransfer), "WARNING: aborting all transactions on
interface %d pipe %d", iface, pipeRef);
/* abort transactions */
(*(cInterface->interface))->AbortPipe (cInterface->interface, pipeRef);
- _usbi_log (ITRANSFER_CTX (itransfer), LOG_LEVEL_INFO, "calling clear pipe
stall to clear the data toggle bit");
+ usbi_info (ITRANSFER_CTX (itransfer), "calling clear pipe stall to clear the
data toggle bit");
/* clear the data toggle bit */
#if (InterfaceVersion < 190)
@@ -1281,7 +1295,7 @@
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
return darwin_abort_transfers (itransfer);
default:
- _usbi_log (TRANSFER_CTX(transfer), LOG_LEVEL_ERROR, "unknown endpoint type
%d", transfer->type);
+ usbi_err (TRANSFER_CTX(transfer), "unknown endpoint type %d",
transfer->type);
return LIBUSB_ERROR_INVALID_PARAM;
}
}
@@ -1302,7 +1316,7 @@
struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv
*)transfer->dev_handle->os_priv;
UInt32 message;
- _usbi_log (ITRANSFER_CTX (itransfer), LOG_LEVEL_INFO, "an async io operation
has completed");
+ usbi_info (ITRANSFER_CTX (itransfer), "an async io operation has completed");
/* send a completion message to the device's file descriptor */
message = MESSAGE_ASYNC_IO_COMPLETE;
@@ -1312,122 +1326,59 @@
write (priv->fds[1], &arg0, sizeof (UInt32));
}
-static void darwin_bulk_callback (struct usbi_transfer *itransfer,
kern_return_t result, UInt32 io_size) {
- enum libusb_transfer_status status;
-
- _usbi_log (ITRANSFER_CTX (itransfer), LOG_LEVEL_INFO, "handling bulk
completion with status %d", result);
-
+static int darwin_transfer_status (struct usbi_transfer *itransfer,
kern_return_t result) {
switch (result) {
case kIOReturnSuccess:
- status = LIBUSB_TRANSFER_COMPLETED;
- itransfer->transferred += io_size;
- break;
+ return LIBUSB_TRANSFER_COMPLETED;
case kIOReturnAborted:
- usbi_handle_transfer_cancellation(itransfer);
- return;
+ return LIBUSB_TRANSFER_CANCELLED;
case kIOUSBPipeStalled:
- _usbi_log (ITRANSFER_CTX (itransfer), LOG_LEVEL_WARNING, "bulk error. pipe
is stalled");
- status = LIBUSB_TRANSFER_STALL;
-
- break;
+ usbi_warn (ITRANSFER_CTX (itransfer), "transfer error: pipe is stalled");
+ return LIBUSB_TRANSFER_STALL;
case kIOReturnOverrun:
- _usbi_log (ITRANSFER_CTX (itransfer), LOG_LEVEL_ERROR, "bulk error. data
overrun", darwin_error_str (result));
- status = LIBUSB_TRANSFER_OVERFLOW;
-
- break;
+ usbi_err (ITRANSFER_CTX (itransfer), "transfer error: data overrun",
darwin_error_str (result));
+ return LIBUSB_TRANSFER_OVERFLOW;
+ case kIOUSBTransactionTimeout:
+ usbi_err (ITRANSFER_CTX (itransfer), "transfer error: timed out");
+ return LIBUSB_TRANSFER_TIMED_OUT;
default:
- _usbi_log (ITRANSFER_CTX (itransfer), LOG_LEVEL_ERROR, "bulk error = %s
(value = 0x%08x)", darwin_error_str (result), result);
- status = LIBUSB_TRANSFER_ERROR;
+ usbi_err (ITRANSFER_CTX (itransfer), "transfer error: %s (value =
0x%08x)", darwin_error_str (result), result);
+ return LIBUSB_TRANSFER_ERROR;
}
-
- usbi_handle_transfer_completion(itransfer, status);
}
-static void darwin_isoc_callback (struct usbi_transfer *itransfer,
kern_return_t result) {
+static void darwin_handle_callback (struct usbi_transfer *itransfer,
kern_return_t result, UInt32 io_size) {
struct libusb_transfer *transfer =
__USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
struct darwin_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer);
- int i, status;
-
- _usbi_log (ITRANSFER_CTX (itransfer), LOG_LEVEL_INFO, "handling isoc
completion with status %d", result);
-
- if (result == kIOReturnSuccess && tpriv->isoc_framelist) {
- /* copy isochronous results back */
-
- for (i = 0; i < transfer->num_iso_packets ; i++) {
- struct libusb_iso_packet_descriptor *lib_desc =
transfer->iso_packet_desc;
- lib_desc->status = darwin_to_libusb (tpriv->isoc_framelist[i].frStatus);
- lib_desc->actual_length = tpriv->isoc_framelist[i].frActCount;
- }
- }
+ int isIsoc = LIBUSB_TRANSFER_TYPE_ISOCHRONOUS == transfer->type;
+ int isBulk = LIBUSB_TRANSFER_TYPE_BULK == transfer->type;
+ int isControl = LIBUSB_TRANSFER_TYPE_CONTROL == transfer->type;
+ int isInterrupt = LIBUSB_TRANSFER_TYPE_INTERRUPT == transfer->type;
+ int i;
- switch (result) {
- case kIOReturnSuccess:
- status = LIBUSB_TRANSFER_COMPLETED;
- break;
- case kIOReturnAborted:
- usbi_handle_transfer_cancellation(itransfer);
+ if (!isIsoc && !isBulk && !isControl && !isInterrupt) {
+ usbi_err (TRANSFER_CTX(transfer), "unknown endpoint type %d",
transfer->type);
return;
- case kIOUSBPipeStalled:
- _usbi_log (ITRANSFER_CTX (itransfer), LOG_LEVEL_WARNING, "unsupported
control request");
- status = LIBUSB_TRANSFER_STALL;
-
- break;
- case kIOReturnOverrun:
- _usbi_log (ITRANSFER_CTX (itransfer), LOG_LEVEL_ERROR, "bulk error. data
overrun", darwin_error_str (result));
- status = LIBUSB_TRANSFER_OVERFLOW;
-
- break;
- default:
- _usbi_log (ITRANSFER_CTX (itransfer), LOG_LEVEL_ERROR, "control error =
%s", darwin_error_str (result));
- status = LIBUSB_TRANSFER_ERROR;
}
- usbi_handle_transfer_completion(itransfer, status);
-}
-
-static void darwin_control_callback (struct usbi_transfer *itransfer,
kern_return_t result, UInt32 io_size) {
- int status;
-
- _usbi_log (ITRANSFER_CTX (itransfer), LOG_LEVEL_INFO, "handling control
completion with status %d", result);
+ usbi_info (ITRANSFER_CTX (itransfer), "handling %s completion with kernel
status %d",
+ isControl ? "control" : isBulk ? "bulk" : isIsoc ? "isoc" :
"interrupt", result);
- switch (result) {
- case kIOReturnSuccess:
- status = LIBUSB_TRANSFER_COMPLETED;
- itransfer->transferred += io_size;
- break;
- case kIOReturnAborted:
- usbi_handle_transfer_cancellation(itransfer);
- return;
- case kIOUSBPipeStalled:
- _usbi_log (ITRANSFER_CTX (itransfer), LOG_LEVEL_WARNING, "unsupported
control request");
- status = LIBUSB_TRANSFER_STALL;
-
- break;
- default:
- _usbi_log (ITRANSFER_CTX (itransfer), LOG_LEVEL_ERROR, "control error =
%s", darwin_error_str (result));
- status = LIBUSB_TRANSFER_ERROR;
+ if (kIOReturnSuccess == result) {
+ if (isIsoc && tpriv->isoc_framelist) {
+ /* copy isochronous results back */
+
+ for (i = 0; i < transfer->num_iso_packets ; i++) {
+ struct libusb_iso_packet_descriptor *lib_desc =
transfer->iso_packet_desc;
+ lib_desc->status = darwin_to_libusb (tpriv->isoc_framelist[i].frStatus);
+ lib_desc->actual_length = tpriv->isoc_framelist[i].frActCount;
+ }
+ } else if (!isIsoc)
+ itransfer->transferred += io_size;
}
- usbi_handle_transfer_completion(itransfer, status);
-}
-
-static void darwin_handle_callback (struct usbi_transfer *itransfer,
kern_return_t result, UInt32 io_size) {
- struct libusb_transfer *transfer =
__USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
-
- switch (transfer->type) {
- case LIBUSB_TRANSFER_TYPE_CONTROL:
- darwin_control_callback (itransfer, result, io_size);
- break;
- case LIBUSB_TRANSFER_TYPE_BULK:
- case LIBUSB_TRANSFER_TYPE_INTERRUPT:
- darwin_bulk_callback (itransfer, result, io_size);
- break;
- case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
- darwin_isoc_callback (itransfer, result);
- break;
- default:
- _usbi_log (TRANSFER_CTX(transfer), LOG_LEVEL_ERROR, "unknown endpoint type
%d", transfer->type);
- }
+ /* it is ok to handle cancelled transfers without calling
usbi_handle_transfer_cancellation (we catch timeout transfers) */
+ usbi_handle_transfer_completion (itransfer, darwin_transfer_status
(itransfer, result));
}
static int op_handle_events(struct libusb_context *ctx, struct pollfd *fds,
nfds_t nfds, int num_ready) {
@@ -1443,7 +1394,7 @@
struct libusb_device_handle *handle;
struct darwin_device_handle_priv *hpriv = NULL;
- _usbi_log (ctx, LOG_LEVEL_INFO, "checking fd %i with revents = %x",
fds[i], pollfd->revents);
+ usbi_info (ctx, "checking fd %i with revents = %x", fds[i],
pollfd->revents);
if (!pollfd->revents)
continue;
@@ -1486,7 +1437,7 @@
darwin_handle_callback (itransfer, kresult, io_size);
break;
default:
- _usbi_log (ctx, LOG_LEVEL_ERROR, "unknown message received from device
pipe");
+ usbi_err (ctx, "unknown message received from device pipe");
}
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/libusb-1.0.6/libusb/os/linux_usbfs.c
new/libusb-1.0.8/libusb/os/linux_usbfs.c
--- old/libusb-1.0.6/libusb/os/linux_usbfs.c 2009-11-22 18:17:46.000000000
+0100
+++ new/libusb-1.0.8/libusb/os/linux_usbfs.c 2010-04-22 23:14:46.000000000
+0200
@@ -72,14 +72,21 @@
static const char *usbfs_path = NULL;
-/* Linux 2.6.32 adds support for a bulk continuation URB flag. this should
- * be set on all URBs in the transfer except the first. also set the
- * SHORT_NOT_OK flag on all of them, to raise error conditions on short
- * transfers.
- * then, on any error except a cancellation, all URBs until the next
- * non-continuation URB will be cancelled with the endpoint disabled,
- * meaning that no more data can creep in during the time it takes us to
- * cancel the remaining URBs. */
+/* Linux 2.6.32 adds support for a bulk continuation URB flag. this basically
+ * allows us to mark URBs as being part of a specific logical transfer when
+ * we submit them to the kernel. then, on any error error except a
+ * cancellation, all URBs within that transfer will be cancelled with the
+ * endpoint is disabled, meaning that no more data can creep in during the
+ * time it takes to cancel the remaining URBs.
+ *
+ * The BULK_CONTINUATION flag must be set on all URBs within a bulk transfer
+ * (in either direction) except the first.
+ * For IN transfers, we must also set SHORT_NOT_OK on all the URBs.
+ * For OUT transfers, SHORT_NOT_OK must not be set. The effective behaviour
+ * (where an OUT transfer does not complete, the rest of the URBs in the
+ * transfer get cancelled) is already in effect, and setting this flag is
+ * disallowed (a kernel with USB debugging enabled will reject such URBs).
+ */
static int supports_flag_bulk_continuation = -1;
/* clock ID for monotonic clock, as not all clock sources are available on all
@@ -381,7 +388,8 @@
/* takes a usbfs/descriptors fd seeked to the start of a configuration, and
* seeks to the next one. */
-static int seek_to_next_config(struct libusb_context *ctx, int fd)
+static int seek_to_next_config(struct libusb_context *ctx, int fd,
+ int host_endian)
{
struct libusb_config_descriptor config;
unsigned char tmp[6];
@@ -399,7 +407,7 @@
}
/* seek forward to end of config */
- usbi_parse_descriptor(tmp, "bbwbb", &config, 1);
+ usbi_parse_descriptor(tmp, "bbwbb", &config, host_endian);
off = lseek(fd, config.wTotalLength - sizeof(tmp), SEEK_CUR);
if (off < 0) {
usbi_err(ctx, "seek failed ret=%d errno=%d", off, errno);
@@ -476,7 +484,7 @@
if (off < 0)
return LIBUSB_ERROR_IO;
- r = seek_to_next_config(DEVICE_CTX(dev), fd);
+ r = seek_to_next_config(DEVICE_CTX(dev), fd, 1);
if (r < 0)
return r;
}
@@ -531,7 +539,7 @@
/* might need to skip some configuration descriptors to reach the
* requested configuration */
while (config_index > 0) {
- r = seek_to_next_config(ctx, fd);
+ r = seek_to_next_config(ctx, fd, 0);
if (r < 0)
return r;
config_index--;
@@ -606,7 +614,7 @@
return r;
}
- usbi_parse_descriptor(tmp, "bbw", &config, 1);
+ usbi_parse_descriptor(tmp, "bbw", &config, 0);
buf = malloc(config.wTotalLength);
if (!buf)
return LIBUSB_ERROR_NO_MEM;
@@ -645,7 +653,8 @@
if (errno == ENODEV)
return LIBUSB_ERROR_NO_DEVICE;
- usbi_err(DEVICE_CTX(dev),
+ /* we hit this error path frequently with buggy devices :( */
+ usbi_warn(DEVICE_CTX(dev),
"get_configuration failed ret=%d errno=%d", r, errno);
return LIBUSB_ERROR_IO;
}
@@ -715,7 +724,13 @@
"determine active configuration descriptor",
path);
} else {
active_config = usbfs_get_active_config(dev, fd);
- if (active_config < 0) {
+ if (active_config == LIBUSB_ERROR_IO) {
+ /* buggy devices sometimes fail to report their
active config.
+ * assume unconfigured and continue the probing
*/
+ usbi_warn(DEVICE_CTX(dev), "couldn't query
active "
+ "configuration, assumung unconfigured");
+ device_configured = 0;
+ } else if (active_config < 0) {
close(fd);
return active_config;
} else if (active_config == 0) {
@@ -724,7 +739,7 @@
* not support buggy devices in these
circumstances.
* stick to the specs: a configuration value of
0 means
* unconfigured. */
- usbi_dbg("assuming unconfigured device");
+ usbi_dbg("active cfg 0? assuming unconfigured
device");
device_configured = 0;
}
}
@@ -1326,6 +1341,8 @@
struct linux_device_handle_priv *dpriv =
__device_handle_priv(transfer->dev_handle);
struct usbfs_urb *urbs;
+ int is_out = (transfer->endpoint & LIBUSB_ENDPOINT_DIR_MASK)
+ == LIBUSB_ENDPOINT_OUT;
int r;
int i;
size_t alloc_size;
@@ -1364,7 +1381,7 @@
urb->type = urb_type;
urb->endpoint = transfer->endpoint;
urb->buffer = transfer->buffer + (i * MAX_BULK_BUFFER_LENGTH);
- if (supports_flag_bulk_continuation)
+ if (supports_flag_bulk_continuation && !is_out)
urb->flags = USBFS_URB_SHORT_NOT_OK;
if (i == num_urbs - 1 && last_urb_partial)
urb->buffer_length = transfer->length %
MAX_BULK_BUFFER_LENGTH;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/libusb-1.0.6/NEWS new/libusb-1.0.8/NEWS
--- old/libusb-1.0.6/NEWS 2009-11-22 18:20:44.000000000 +0100
+++ new/libusb-1.0.8/NEWS 2010-05-05 00:01:54.000000000 +0200
@@ -1,6 +1,13 @@
This file lists notable changes in each release. For the full history of all
changes, see ChangeLog.
+2010-05-07: v1.0.8
+* Bug fixes
+
+2010-04-19: v1.0.7
+* Bug fixes and documentation tweaks
+* Add more interface class definitions
+
2009-11-22: v1.0.6
* Bug fixes
* Increase libusb_handle_events() timeout to 60s for powersaving
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-commit+help@xxxxxxxxxxxx
| < Previous | Next > |