From patchwork Tue Jan 8 13:14:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 210416 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DA3052C0093 for ; Wed, 9 Jan 2013 01:50:56 +1100 (EST) Received: from localhost ([::1]:52326 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsZ2L-0006JV-BO for incoming@patchwork.ozlabs.org; Tue, 08 Jan 2013 08:16:13 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsZ1H-0004Pe-WB for qemu-devel@nongnu.org; Tue, 08 Jan 2013 08:15:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TsZ1A-0002eJ-2D for qemu-devel@nongnu.org; Tue, 08 Jan 2013 08:15:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:24224) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsZ19-0002di-Py for qemu-devel@nongnu.org; Tue, 08 Jan 2013 08:14:59 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r08DExKQ024634 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 8 Jan 2013 08:14:59 -0500 Received: from rincewind.home.kraxel.org (ovpn-116-40.ams2.redhat.com [10.36.116.40]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r08DEwpc014459; Tue, 8 Jan 2013 08:14:58 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 8DB2F41A42; Tue, 8 Jan 2013 14:14:54 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 8 Jan 2013 14:14:29 +0100 Message-Id: <1357650894-16982-8-git-send-email-kraxel@redhat.com> In-Reply-To: <1357650894-16982-1-git-send-email-kraxel@redhat.com> References: <1357650894-16982-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Hans de Goede , Gerd Hoffmann Subject: [Qemu-devel] [PATCH 07/32] ehci: Add an ehci_get_pid helper function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Hans de Goede Signed-off-by: Hans de Goede Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ehci.c | 32 ++++++++++++++++---------------- 1 files changed, 16 insertions(+), 16 deletions(-) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index dde2ff3..dae414a 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -481,6 +481,21 @@ static inline int put_dwords(EHCIState *ehci, uint32_t addr, return num; } +static int ehci_get_pid(EHCIqtd *qtd) +{ + switch (get_field(qtd->token, QTD_TOKEN_PID)) { + case 0: + return USB_TOKEN_OUT; + case 1: + return USB_TOKEN_IN; + case 2: + return USB_TOKEN_SETUP; + default: + fprintf(stderr, "bad token\n"); + return 0; + } +} + static bool ehci_verify_qh(EHCIQueue *q, EHCIqh *qh) { uint32_t devaddr = get_field(qh->epchar, QH_EPCHAR_DEVADDR); @@ -1352,22 +1367,7 @@ static int ehci_execute(EHCIPacket *p, const char *action) return -1; } - p->pid = (p->qtd.token & QTD_TOKEN_PID_MASK) >> QTD_TOKEN_PID_SH; - switch (p->pid) { - case 0: - p->pid = USB_TOKEN_OUT; - break; - case 1: - p->pid = USB_TOKEN_IN; - break; - case 2: - p->pid = USB_TOKEN_SETUP; - break; - default: - fprintf(stderr, "bad token\n"); - break; - } - + p->pid = ehci_get_pid(&p->qtd); endp = get_field(p->queue->qh.epchar, QH_EPCHAR_EP); ep = usb_ep_get(p->queue->dev, p->pid, endp);