Received: from eggs.gnu.org ([2001:4830:134:3::10]:44727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOBH1-0005sV-S7 for qemu-devel@nongnu.org; Mon, 23 Sep 2013 14:54:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VOBGv-0002I6-Ol for qemu-devel@nongnu.org; Mon, 23 Sep 2013 14:54:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64746) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOBGv-0002Hn-GA for qemu-devel@nongnu.org; Mon, 23 Sep 2013 14:54:13 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8NIsCxt002839 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 23 Sep 2013 14:54:12 -0400 From: Hans de Goede Date: Mon, 23 Sep 2013 20:54:02 +0200 Message-Id: <1379962447-5431-3-git-send-email-hdegoede@redhat.com> In-Reply-To: <1379962447-5431-1-git-send-email-hdegoede@redhat.com> References: <1379962447-5431-1-git-send-email-hdegoede@redhat.com> Subject: [Qemu-devel] [PATCH 2/7] usb-host-libusb: Configuration 0 may be a valid configuration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: Hans de Goede , qemu-devel@nongnu.org Quoting from: linux/Documentation/ABI/stable/sysfs-bus-usb: Note that some devices, in violation of the USB spec, have a configuration with a value equal to 0. Writing 0 to bConfigurationValue for these devices will install that configuration, rather then unconfigure the device. So don't compare the configuration value against 0 to check for unconfigured devices, instead check for a LIBUSB_ERROR_NOT_FOUND return from libusb_get_active_config_descriptor(). Signed-off-by: Hans de Goede --- hw/usb/host-libusb.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index 09a8a73..f267fd4 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -1004,15 +1004,14 @@ static int usb_host_claim_interfaces(USBHostDevice *s, int configuration) udev->ninterfaces = 0; udev->configuration = 0; - if (configuration == 0) { - /* address state - ignore */ - return USB_RET_SUCCESS; - } - usb_host_detach_kernel(s); rc = libusb_get_active_config_descriptor(s->dev, &conf); if (rc != 0) { + if (rc == LIBUSB_ERROR_NOT_FOUND) { + /* address state - ignore */ + return USB_RET_SUCCESS; + } return USB_RET_STALL; } -- 1.8.3.1