From patchwork Tue Feb 28 10:20:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 143433 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 4F348B6EEE for ; Tue, 28 Feb 2012 22:50:52 +1100 (EST) Received: from localhost ([::1]:38409 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2KBn-0000Dg-OT for incoming@patchwork.ozlabs.org; Tue, 28 Feb 2012 05:21:47 -0500 Received: from eggs.gnu.org ([208.118.235.92]:34241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2KAq-0006ng-H3 for qemu-devel@nongnu.org; Tue, 28 Feb 2012 05:20:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S2KAj-00041D-B8 for qemu-devel@nongnu.org; Tue, 28 Feb 2012 05:20:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:22097) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2KAj-00040Z-3A for qemu-devel@nongnu.org; Tue, 28 Feb 2012 05:20:41 -0500 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 q1SAKdsR006295 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 28 Feb 2012 05:20:39 -0500 Received: from rincewind.home.kraxel.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q1SAKZXu000462; Tue, 28 Feb 2012 05:20:36 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id C414140CA5; Tue, 28 Feb 2012 11:20:30 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 28 Feb 2012 11:20:14 +0100 Message-Id: <1330424430-23015-6-git-send-email-kraxel@redhat.com> In-Reply-To: <1330424430-23015-1-git-send-email-kraxel@redhat.com> References: <1330424430-23015-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 05/21] usb-uhci: process uhci_handle_td return code via switch. 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 Restruct the uhci_handle_td return code processing to make the control flow more clear and the code more readable. Signed-off-by: Gerd Hoffmann --- hw/usb-uhci.c | 66 +++++++++++++++++++++++++++++++++----------------------- 1 files changed, 39 insertions(+), 27 deletions(-) diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c index b8b336f..13298aa 100644 --- a/hw/usb-uhci.c +++ b/hw/usb-uhci.c @@ -1029,49 +1029,61 @@ static void uhci_process_frame(UHCIState *s) pci_dma_write(&s->dev, (link & ~0xf) + 4, &val, sizeof(val)); } - if (ret < 0) { - /* interrupted frame */ - break; - } - - if (ret == 2 || ret == 1) { - DPRINTF("uhci: TD 0x%x %s. link 0x%x ctrl 0x%x token 0x%x qh 0x%x\n", - link, ret == 2 ? "pend" : "skip", - td.link, td.ctrl, td.token, curr_qh); + switch (ret) { + case -1: /* interrupted frame */ + goto out; + case 1: /* goto next queue */ + DPRINTF("uhci: TD 0x%x skip. " + "link 0x%x ctrl 0x%x token 0x%x qh 0x%x\n", + link, td.link, td.ctrl, td.token, curr_qh); link = curr_qh ? qh.link : td.link; continue; - } - /* completed TD */ + case 2: /* got USB_RET_ASYNC */ + DPRINTF("uhci: TD 0x%x async. " + "link 0x%x ctrl 0x%x token 0x%x qh 0x%x\n", + link, td.link, td.ctrl, td.token, curr_qh); + fprintf(stderr, "async td: link %x%s\n", + td.link, is_valid(td.link) ? " valid" : ""); + link = curr_qh ? qh.link : td.link; + continue; - DPRINTF("uhci: TD 0x%x done. link 0x%x ctrl 0x%x token 0x%x qh 0x%x\n", - link, td.link, td.ctrl, td.token, curr_qh); + case 0: /* completed TD */ + DPRINTF("uhci: TD 0x%x done. " + "link 0x%x ctrl 0x%x token 0x%x qh 0x%x\n", + link, td.link, td.ctrl, td.token, curr_qh); - link = td.link; - td_count++; - bytes_count += (td.ctrl & 0x7ff) + 1; + link = td.link; + td_count++; + bytes_count += (td.ctrl & 0x7ff) + 1; - if (curr_qh) { - /* update QH element link */ - qh.el_link = link; - val = cpu_to_le32(qh.el_link); - pci_dma_write(&s->dev, (curr_qh & ~0xf) + 4, &val, sizeof(val)); + if (curr_qh) { + /* update QH element link */ + qh.el_link = link; + val = cpu_to_le32(qh.el_link); + pci_dma_write(&s->dev, (curr_qh & ~0xf) + 4, &val, sizeof(val)); - if (!depth_first(link)) { - /* done with this QH */ + if (!depth_first(link)) { + /* done with this QH */ - DPRINTF("uhci: QH 0x%x done. link 0x%x elink 0x%x\n", - curr_qh, qh.link, qh.el_link); + DPRINTF("uhci: QH 0x%x done. link 0x%x elink 0x%x\n", + curr_qh, qh.link, qh.el_link); - curr_qh = 0; - link = qh.link; + curr_qh = 0; + link = qh.link; + } } + break; + + default: + assert(!"unknown return code"); } /* go to the next entry */ } +out: s->pending_int_mask |= int_mask; }