qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 05/21] usb-uhci: process uhci_handle_td return code via switch.
Date: Tue, 28 Feb 2012 11:20:14 +0100	[thread overview]
Message-ID: <1330424430-23015-6-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1330424430-23015-1-git-send-email-kraxel@redhat.com>

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 <kraxel@redhat.com>
---
 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;
 }
 
-- 
1.7.1

  parent reply	other threads:[~2012-02-28 10:20 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-28 10:20 [Qemu-devel] [PULL] usb patch queue Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 01/21] usb-hid: fix tablet activation Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 02/21] usb-ehci: fix reset Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 03/21] usb-uhci: cleanup UHCIAsync allocation & initialization Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 04/21] usb-uhci: add UHCIQueue Gerd Hoffmann
2012-02-28 10:20 ` Gerd Hoffmann [this message]
2012-02-28 10:20 ` [Qemu-devel] [PATCH 06/21] usb-uhci: implement packet queuing Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 07/21] usb-xhci: enable " Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 08/21] usb: add tracepoint for usb packet state changes Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 09/21] usb-ehci: sanity-check iso xfers Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 10/21] usb-desc: fix user trigerrable segfaults (!config) Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 11/21] libcacard: link with glib for g_strndup Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 12/21] usb-ccid: advertise SELF_POWERED Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 13/21] libcacard: fix reported ATR length Gerd Hoffmann
2012-03-08  7:12   ` Wen Congyang
2012-03-08  8:15     ` Alon Levy
2012-02-28 10:20 ` [Qemu-devel] [PATCH 14/21] usb-ehci: Handle ISO packets failing with an error other then NAK Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 15/21] ehci: drop old stuff Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 16/21] usb-redir: Fix printing of device version Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 17/21] usb-redir: Always clear device state on filter reject Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 18/21] usb-redir: Let the usb-host know about our device filtering Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 19/21] usb-redir: Limit return values returned by iso packets Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 20/21] usb-redir: Return USB_RET_NAK when we've no data for an interrupt endpoint Gerd Hoffmann
2012-02-28 10:20 ` [Qemu-devel] [PATCH 21/21] usb: Resolve warnings about unassigned bus on usb device creation Gerd Hoffmann
2012-02-29 21:07 ` [Qemu-devel] [PULL] usb patch queue Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1330424430-23015-6-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).