qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Sven Schnelle <svens@stackframe.org>
Subject: [Qemu-devel] [PULL v2 24/31] lsi: use enum type for s->msg_action
Date: Mon, 11 Mar 2019 17:55:28 +0100	[thread overview]
Message-ID: <1552323335-46779-25-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1552323335-46779-1-git-send-email-pbonzini@redhat.com>

From: Sven Schnelle <svens@stackframe.org>

This makes the code easier to read - no functional change.

Signed-off-by: Sven Schnelle <svens@stackframe.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190305195519.24303-4-svens@stackframe.org>
---
 hw/scsi/lsi53c895a.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index c17bb4f..d67584e 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -201,6 +201,13 @@ enum {
     LSI_DMA_IN_PROGRESS, /* DMA operation is in progress */
 };
 
+enum {
+    LSI_MSG_ACTION_COMMAND = 0,
+    LSI_MSG_ACTION_DISCONNECT = 1,
+    LSI_MSG_ACTION_DOUT = 2,
+    LSI_MSG_ACTION_DIN = 3,
+};
+
 typedef struct {
     /*< private >*/
     PCIDevice parent_obj;
@@ -214,8 +221,6 @@ typedef struct {
 
     int carry; /* ??? Should this be an a visible register somewhere?  */
     int status;
-    /* Action to take at the end of a MSG IN phase.
-       0 = COMMAND, 1 = disconnect, 2 = DATA OUT, 3 = DATA IN.  */
     int msg_action;
     int msg_len;
     uint8_t msg[LSI_MAX_MSGIN_LEN];
@@ -323,7 +328,7 @@ static void lsi_soft_reset(LSIState *s)
     trace_lsi_reset();
     s->carry = 0;
 
-    s->msg_action = 0;
+    s->msg_action = LSI_MSG_ACTION_COMMAND;
     s->msg_len = 0;
     s->waiting = LSI_NOWAIT;
     s->dsa = 0;
@@ -686,7 +691,7 @@ static void lsi_reselect(LSIState *s, lsi_request *p)
     trace_lsi_reselect(id);
     s->scntl1 |= LSI_SCNTL1_CON;
     lsi_set_phase(s, PHASE_MI);
-    s->msg_action = p->out ? 2 : 3;
+    s->msg_action = p->out ? LSI_MSG_ACTION_DOUT : LSI_MSG_ACTION_DIN;
     s->current->dma_len = p->pending;
     lsi_add_msg_byte(s, 0x80);
     if (s->current->tag & LSI_TAG_VALID) {
@@ -857,7 +862,7 @@ static void lsi_do_command(LSIState *s)
             lsi_add_msg_byte(s, 4); /* DISCONNECT */
             /* wait data */
             lsi_set_phase(s, PHASE_MI);
-            s->msg_action = 1;
+            s->msg_action = LSI_MSG_ACTION_DISCONNECT;
             lsi_queue_command(s);
         } else {
             /* wait command complete */
@@ -878,7 +883,7 @@ static void lsi_do_status(LSIState *s)
     s->sfbr = status;
     pci_dma_write(PCI_DEVICE(s), s->dnad, &status, 1);
     lsi_set_phase(s, PHASE_MI);
-    s->msg_action = 1;
+    s->msg_action = LSI_MSG_ACTION_DISCONNECT;
     lsi_add_msg_byte(s, 0); /* COMMAND COMPLETE */
 }
 
@@ -901,16 +906,16 @@ static void lsi_do_msgin(LSIState *s)
         /* ??? Check if ATN (not yet implemented) is asserted and maybe
            switch to PHASE_MO.  */
         switch (s->msg_action) {
-        case 0:
+        case LSI_MSG_ACTION_COMMAND:
             lsi_set_phase(s, PHASE_CMD);
             break;
-        case 1:
+        case LSI_MSG_ACTION_DISCONNECT:
             lsi_disconnect(s);
             break;
-        case 2:
+        case LSI_MSG_ACTION_DOUT:
             lsi_set_phase(s, PHASE_DO);
             break;
-        case 3:
+        case LSI_MSG_ACTION_DIN:
             lsi_set_phase(s, PHASE_DI);
             break;
         default:
@@ -1062,7 +1067,7 @@ bad:
     qemu_log_mask(LOG_UNIMP, "Unimplemented message 0x%02x\n", msg);
     lsi_set_phase(s, PHASE_MI);
     lsi_add_msg_byte(s, 7); /* MESSAGE REJECT */
-    s->msg_action = 0;
+    s->msg_action = LSI_MSG_ACTION_COMMAND;
 }
 
 #define LSI_BUF_SIZE 4096
-- 
1.8.3.1

  parent reply	other threads:[~2019-03-11 16:56 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-11 16:55 [Qemu-devel] [PULL v2 00/31] Misc patches for 2019-03-09 Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 01/31] memory: Do not update coalesced IO range in the case of NOP Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 02/31] vfio-pci: enable by default Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 03/31] riscv/Kconfig: enable PCI_DEVICES Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 04/31] tests: test-qgraph: fix a memory leak Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 05/31] hw/i386/pc: run the multiboot loader before the PVH loader Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 06/31] block/iscsi: Restrict Linux-specific code Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 07/31] contrib/elf2dmp: add kernel start address checking Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 08/31] configure: Enable werror for git worktrees Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 09/31] target-i386: add kvm stubs to user-mode emulators Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 10/31] i386: extended the cpuid_level when Intel PT is enabled Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 11/31] virtio-scsi: Fix build with gcc 9 Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 12/31] lsi: implement basic SBCL functionality Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 13/31] lsi: check if SIGP bit is already set in Wait reselect Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 14/31] update copyright notice Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 15/31] build: get rid of target-obj-y Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 16/31] build: remove unnecessary assignments from Makefile.target Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 17/31] build: clean trace/generated-helpers.c Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 18/31] accel: Allow to build QEMU without TCG or KVM support Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 19/31] oslib-posix: Ignore fcntl("/dev/null", F_SETFL, O_NONBLOCK) failure Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 20/31] configure: Disable W^X on OpenBSD Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 21/31] scsi-disk: Fix crash if request is invaild or disk is no medium Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 22/31] lsi: use ldn_le_p()/stn_le_p() Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 23/31] lsi: use enum type for s->waiting Paolo Bonzini
2019-03-11 16:55 ` Paolo Bonzini [this message]
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 25/31] lsi: use SCSI phase names instead of numbers in trace Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 26/31] lsi: return dfifo value Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 27/31] lsi: 810/895A are always little endian Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 28/31] exec.c: refactor function flatview_add_to_dispatch() Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 29/31] qom: cpu: destroy work_mutex in cpu_common_finalize Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 30/31] chardev: add support for authorization for TLS clients Paolo Bonzini
2019-03-11 16:55 ` [Qemu-devel] [PULL v2 31/31] qemugdb: fix licensing Paolo Bonzini
2019-03-11 19:05 ` [Qemu-devel] [PULL v2 00/31] Misc patches for 2019-03-09 Peter Maydell

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=1552323335-46779-25-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=svens@stackframe.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).