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 5/5] lsi: pass lsi_request to lsi_reselect
Date: Wed,  6 Jan 2010 17:08:04 +0100	[thread overview]
Message-ID: <1262794084-8020-6-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1262794084-8020-1-git-send-email-kraxel@redhat.com>

All callers of lsi_reselect have a lsi_request struct at hand anyway.
So just pass it directly instead of having lsi_reselect search for it
using the tag.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/lsi53c895a.c |   23 +++++++----------------
 1 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
index f28fc76..dbc8c66 100644
--- a/hw/lsi53c895a.c
+++ b/hw/lsi53c895a.c
@@ -371,7 +371,7 @@ static int lsi_dma_64bit(LSIState *s)
 static uint8_t lsi_reg_readb(LSIState *s, int offset);
 static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val);
 static void lsi_execute_script(LSIState *s);
-static void lsi_reselect(LSIState *s, uint32_t tag);
+static void lsi_reselect(LSIState *s, lsi_request *p);
 
 static inline uint32_t read_dword(LSIState *s, uint32_t addr)
 {
@@ -430,7 +430,7 @@ static void lsi_update_irq(LSIState *s)
                 "processes\n");
         QTAILQ_FOREACH(p, &s->queue, next) {
             if (p->pending) {
-                lsi_reselect(s, p->tag);
+                lsi_reselect(s, p);
                 break;
             }
         }
@@ -589,24 +589,15 @@ static void lsi_add_msg_byte(LSIState *s, uint8_t data)
 }
 
 /* Perform reselection to continue a command.  */
-static void lsi_reselect(LSIState *s, uint32_t tag)
+static void lsi_reselect(LSIState *s, lsi_request *p)
 {
-    lsi_request *p;
     int id;
 
-    QTAILQ_FOREACH(p, &s->queue, next) {
-        if (p->tag == tag)
-            break;
-    }
-    if (p == NULL) {
-        BADF("Reselected non-existant command tag=0x%x\n", tag);
-        return;
-    }
     assert(s->current == NULL);
     QTAILQ_REMOVE(&s->queue, p, next);
     s->current = p;
 
-    id = (tag >> 8) & 0xf;
+    id = (p->tag >> 8) & 0xf;
     s->ssid = id | 0x80;
     /* LSI53C700 Family Compatibility, see LSI53C895A 4-73 */
     if (!(s->dcntl & LSI_DCNTL_COM)) {
@@ -620,7 +611,7 @@ static void lsi_reselect(LSIState *s, uint32_t tag)
     lsi_add_msg_byte(s, 0x80);
     if (s->current->tag & LSI_TAG_VALID) {
         lsi_add_msg_byte(s, 0x20);
-        lsi_add_msg_byte(s, tag & 0xff);
+        lsi_add_msg_byte(s, p->tag & 0xff);
     }
 
     if (lsi_irq_on_rsl(s)) {
@@ -649,7 +640,7 @@ static int lsi_queue_tag(LSIState *s, uint32_t tag, uint32_t arg)
                 (lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON) &&
                  !(s->istat0 & (LSI_ISTAT0_SIP | LSI_ISTAT0_DIP)))) {
                 /* Reselect device.  */
-                lsi_reselect(s, tag);
+                lsi_reselect(s, p);
                 return 0;
             } else {
                 DPRINTF("Queueing IO tag=0x%x\n", tag);
@@ -914,7 +905,7 @@ static void lsi_wait_reselect(LSIState *s)
 
     QTAILQ_FOREACH(p, &s->queue, next) {
         if (p->pending) {
-            lsi_reselect(s, p->tag);
+            lsi_reselect(s, p);
             break;
         }
     }
-- 
1.6.5.2

      parent reply	other threads:[~2010-01-06 16:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-06 16:07 [Qemu-devel] [PATCH 0/5] lsi: a bunch of cleanups Gerd Hoffmann
2010-01-06 16:08 ` [Qemu-devel] [PATCH 1/5] lsi: use QTAILQ for lsi_queue Gerd Hoffmann
2010-01-11 16:02   ` Anthony Liguori
2010-01-06 16:08 ` [Qemu-devel] [PATCH 2/5] lsi: have lsi_request for the whole life time of the request Gerd Hoffmann
2010-01-06 16:08 ` [Qemu-devel] [PATCH 3/5] lsi: move current_dev into lsi_request Gerd Hoffmann
2010-01-06 16:08 ` [Qemu-devel] [PATCH 4/5] lsi: move dma_len+dma_buf " Gerd Hoffmann
2010-01-06 16:08 ` Gerd Hoffmann [this message]

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=1262794084-8020-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).