Received: from eggs.gnu.org ([2001:4830:134:3::10]:40492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTdQM-0003CW-NF for qemu-devel@nongnu.org; Tue, 08 Oct 2013 15:58:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTdQG-0004oT-Mh for qemu-devel@nongnu.org; Tue, 08 Oct 2013 15:58:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44688) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTdQG-0004oM-FX for qemu-devel@nongnu.org; Tue, 08 Oct 2013 15:58:24 -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 r98JwN7C024638 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 8 Oct 2013 15:58:23 -0400 From: Hans de Goede Date: Tue, 8 Oct 2013 21:58:07 +0200 Message-Id: <1381262298-3241-3-git-send-email-hdegoede@redhat.com> In-Reply-To: <1381262298-3241-1-git-send-email-hdegoede@redhat.com> References: <1381262298-3241-1-git-send-email-hdegoede@redhat.com> Subject: [Qemu-devel] [PATCH 02/13] 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 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