[PATCH 07/16] lsi53c895a: always use enum constants for s->waiting

Paolo Bonzini posted 16 patches 5 days, 16 hours ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Fam Zheng <fam@euphon.net>, Richard Henderson <richard.henderson@linaro.org>, Helge Deller <deller@gmx.de>
[PATCH 07/16] lsi53c895a: always use enum constants for s->waiting
Posted by Paolo Bonzini 5 days, 16 hours ago
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi/lsi53c895a.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index 6b0c97d98e3..6f65a2188c1 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -201,13 +201,13 @@ typedef struct lsi_request {
     QTAILQ_ENTRY(lsi_request) next;
 } lsi_request;
 
-enum {
+typedef enum {
     LSI_NOWAIT, /* SCRIPTS are running or stopped */
     LSI_WAIT_RESELECT, /* Wait Reselect instruction has been issued */
     LSI_DMA_SCRIPTS, /* processing DMA from lsi_execute_script */
     LSI_DMA_IN_PROGRESS, /* DMA operation is in progress */
     LSI_WAIT_SCRIPTS, /* SCRIPTS stopped because of instruction count limit */
-};
+} LSIWaitState;
 
 typedef enum {
     LSI_CMD_SENT, /* command is running */
@@ -239,7 +239,7 @@ struct LSIState {
     int msg_action;
     int msg_len;
     uint8_t msg[LSI_MAX_MSGIN_LEN];
-    int waiting;
+    LSIWaitState waiting;
     SCSIBus bus;
     int current_lun;
     /* The tag is a combination of the device ID and the SCSI tag.  */
@@ -605,7 +605,7 @@ static int lsi_bad_phase(LSIState *s, int out, int new_phase)
 /* Resume SCRIPTS execution after a DMA operation.  */
 static void lsi_resume_script(LSIState *s)
 {
-    if (s->waiting != 2) {
+    if (s->waiting != LSI_DMA_SCRIPTS) {
         s->waiting = LSI_NOWAIT;
         lsi_execute_script(s);
     } else {
@@ -822,11 +822,11 @@ static void lsi_command_complete(SCSIRequest *req, size_t resid)
     trace_lsi_command_complete(req->status);
     s->status = req->status;
     s->command_complete = LSI_CMD_COMPLETE;
-    if (s->waiting && s->dbc != 0) {
+    if (s->waiting != LSI_NOWAIT && s->dbc != 0) {
         /* Raise phase mismatch for short transfers.  */
         stop = lsi_bad_phase(s, out, PHASE_ST);
         if (stop) {
-            s->waiting = 0;
+            s->waiting = LSI_NOWAIT;
         }
     } else {
         lsi_set_phase(s, PHASE_ST);
@@ -861,7 +861,7 @@ static void lsi_transfer_data(SCSIRequest *req, uint32_t len)
     trace_lsi_transfer_data(req->tag, len);
     s->current->dma_len = len;
     s->command_complete = LSI_CMD_READY;
-    if (s->waiting) {
+    if (s->waiting != LSI_NOWAIT) {
         if (s->waiting == LSI_WAIT_RESELECT || s->dbc == 0) {
             lsi_resume_script(s);
         } else {
-- 
2.53.0
Re: [PATCH 07/16] lsi53c895a: always use enum constants for s->waiting
Posted by Philippe Mathieu-Daudé 5 days, 14 hours ago
On 27/3/26 22:25, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   hw/scsi/lsi53c895a.c | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>