From patchwork Wed Nov 10 09:06:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 70616 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 69772B70EF for ; Wed, 10 Nov 2010 20:13:32 +1100 (EST) Received: from localhost ([127.0.0.1]:54862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PG6k2-0003Zt-Va for incoming@patchwork.ozlabs.org; Wed, 10 Nov 2010 04:13:19 -0500 Received: from [140.186.70.92] (port=53808 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PG6cX-0000OL-Ar for qemu-devel@nongnu.org; Wed, 10 Nov 2010 04:05:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PG6cW-0007OS-6s for qemu-devel@nongnu.org; Wed, 10 Nov 2010 04:05:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:16741) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PG6cV-0007O8-WE for qemu-devel@nongnu.org; Wed, 10 Nov 2010 04:05:32 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAA95VI3018958 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 10 Nov 2010 04:05:31 -0500 Received: from shalem.localdomain (vpn1-5-48.ams2.redhat.com [10.36.5.48]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oAA95Q4B021677; Wed, 10 Nov 2010 04:05:29 -0500 From: Hans de Goede To: qemu-devel@nongnu.org Date: Wed, 10 Nov 2010 10:06:24 +0100 Message-Id: <1289379985-12554-3-git-send-email-hdegoede@redhat.com> In-Reply-To: <1289379985-12554-1-git-send-email-hdegoede@redhat.com> References: <1289379985-12554-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: spice-devel@lists.freedesktop.org, Gerd Hoffmann , Hans de Goede Subject: [Qemu-devel] [PATCH 2/3] usb-linux: introduce a usb_linux_get_configuration function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The next patch in this series introduces multiple ways to get the configuration dependent upon usb_fs_type, it is cleaner to put this into its own function. --- usb-linux.c | 30 ++++++++++++++++++++++-------- 1 files changed, 22 insertions(+), 8 deletions(-) diff --git a/usb-linux.c b/usb-linux.c index 0b154c2..111fe1c 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -775,13 +775,11 @@ static int usb_host_handle_packet(USBDevice *s, USBPacket *p) } } -/* returns 1 on problem encountered or 0 for success */ -static int usb_linux_update_endp_table(USBHostDevice *s) +static int usb_linux_get_configuration(USBHostDevice *s) { - uint8_t *descriptors; - uint8_t devep, type, configuration, alt_interface; + uint8_t configuration; struct usb_ctrltransfer ct; - int interface, ret, length, i; + int ret; ct.bRequestType = USB_DIR_IN; ct.bRequest = USB_REQ_GET_CONFIGURATION; @@ -793,15 +791,31 @@ static int usb_linux_update_endp_table(USBHostDevice *s) ret = ioctl(s->fd, USBDEVFS_CONTROL, &ct); if (ret < 0) { - perror("usb_linux_update_endp_table"); - return 1; + perror("usb_linux_get_configuration"); + return -1; } /* in address state */ if (configuration == 0) { - return 1; + return -1; } + return configuration; +} + +/* returns 1 on problem encountered or 0 for success */ +static int usb_linux_update_endp_table(USBHostDevice *s) +{ + uint8_t *descriptors; + uint8_t devep, type, configuration, alt_interface; + struct usb_ctrltransfer ct; + int interface, ret, length, i; + + i = usb_linux_get_configuration(s); + if (i < 0) + return 1; + configuration = i; + /* get the desired configuration, interface, and endpoint descriptors * from device description */ descriptors = &s->descr[18];