From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZKhO-00074t-IH for qemu-devel@nongnu.org; Thu, 24 Oct 2013 09:11:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VZKhE-0001XS-3I for qemu-devel@nongnu.org; Thu, 24 Oct 2013 09:11:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43687) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZKhD-0001Ww-Om for qemu-devel@nongnu.org; Thu, 24 Oct 2013 09:11:28 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9ODBRts027972 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 24 Oct 2013 09:11:27 -0400 From: Gerd Hoffmann Date: Thu, 24 Oct 2013 15:11:02 +0200 Message-Id: <1382620267-18065-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1382620267-18065-1-git-send-email-kraxel@redhat.com> References: <1382620267-18065-1-git-send-email-kraxel@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: qemu-devel@nongnu.org Cc: Hans de Goede , Gerd Hoffmann From: Hans de Goede 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 Signed-off-by: Gerd Hoffmann --- 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 428c7c5..35bae55 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -992,15 +992,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