diff mbox series

[039/117] cxlflash: Convert to the scsi_status union

Message ID 20210420000845.25873-40-bvanassche@acm.org
State New
Headers show
Series Make better use of static type checking | expand

Commit Message

Bart Van Assche April 20, 2021, 12:07 a.m. UTC
An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".

Cc: Manoj N. Kumar <manoj@linux.ibm.com>
Cc: Matthew R. Ochs <mrochs@linux.ibm.com>
Cc: Uma Krishnan <ukrishn@linux.ibm.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/cxlflash/main.c      | 32 +++++++++++++++----------------
 drivers/scsi/cxlflash/superpipe.c | 16 ++++++++--------
 2 files changed, 24 insertions(+), 24 deletions(-)
diff mbox series

Patch

diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index dc36531d589e..8c5c28f29911 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -59,7 +59,7 @@  static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp)
 	if (ioasa->rc.flags & SISL_RC_FLAGS_OVERRUN) {
 		dev_dbg(dev, "%s: cmd underrun cmd = %p scp = %p\n",
 			__func__, cmd, scp);
-		scp->result = (DID_ERROR << 16);
+		scp->status.combined = (DID_ERROR << 16);
 	}
 
 	dev_dbg(dev, "%s: cmd failed afu_rc=%02x scsi_rc=%02x fc_rc=%02x "
@@ -72,20 +72,20 @@  static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp)
 		if (ioasa->rc.flags & SISL_RC_FLAGS_SENSE_VALID) {
 			memcpy(scp->sense_buffer, ioasa->sense_data,
 			       SISL_SENSE_DATA_LEN);
-			scp->result = ioasa->rc.scsi_rc;
+			scp->status.combined = ioasa->rc.scsi_rc;
 		} else
-			scp->result = ioasa->rc.scsi_rc | (DID_ERROR << 16);
+			scp->status.combined = ioasa->rc.scsi_rc | (DID_ERROR << 16);
 	}
 
 	/*
-	 * We encountered an error. Set scp->result based on nature
+	 * We encountered an error. Set scp->status based on nature
 	 * of error.
 	 */
 	if (ioasa->rc.fc_rc) {
 		/* We have an FC status */
 		switch (ioasa->rc.fc_rc) {
 		case SISL_FC_RC_LINKDOWN:
-			scp->result = (DID_REQUEUE << 16);
+			scp->status.combined = (DID_REQUEUE << 16);
 			break;
 		case SISL_FC_RC_RESID:
 			/* This indicates an FCP resid underrun */
@@ -95,7 +95,7 @@  static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp)
 				 * If not then we must handle it here.
 				 * This is probably an AFU bug.
 				 */
-				scp->result = (DID_ERROR << 16);
+				scp->status.combined = (DID_ERROR << 16);
 			}
 			break;
 		case SISL_FC_RC_RESIDERR:
@@ -108,7 +108,7 @@  static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp)
 		case SISL_FC_RC_WRABORTPEND:
 		case SISL_FC_RC_NOEXP:
 		case SISL_FC_RC_INUSE:
-			scp->result = (DID_ERROR << 16);
+			scp->status.combined = (DID_ERROR << 16);
 			break;
 		}
 	}
@@ -117,25 +117,25 @@  static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp)
 		/* We have an AFU error */
 		switch (ioasa->rc.afu_rc) {
 		case SISL_AFU_RC_NO_CHANNELS:
-			scp->result = (DID_NO_CONNECT << 16);
+			scp->status.combined = (DID_NO_CONNECT << 16);
 			break;
 		case SISL_AFU_RC_DATA_DMA_ERR:
 			switch (ioasa->afu_extra) {
 			case SISL_AFU_DMA_ERR_PAGE_IN:
 				/* Retry */
-				scp->result = (DID_IMM_RETRY << 16);
+				scp->status.combined = (DID_IMM_RETRY << 16);
 				break;
 			case SISL_AFU_DMA_ERR_INVALID_EA:
 			default:
-				scp->result = (DID_ERROR << 16);
+				scp->status.combined = (DID_ERROR << 16);
 			}
 			break;
 		case SISL_AFU_RC_OUT_OF_DATA_BUFS:
 			/* Retry */
-			scp->result = (DID_ALLOC_FAILURE << 16);
+			scp->status.combined = (DID_ALLOC_FAILURE << 16);
 			break;
 		default:
-			scp->result = (DID_ERROR << 16);
+			scp->status.combined = (DID_ERROR << 16);
 		}
 	}
 }
@@ -167,10 +167,10 @@  static void cmd_complete(struct afu_cmd *cmd)
 		if (unlikely(cmd->sa.ioasc))
 			process_cmd_err(cmd, scp);
 		else
-			scp->result = (DID_OK << 16);
+			scp->status.combined = (DID_OK << 16);
 
 		dev_dbg_ratelimited(dev, "%s:scp=%p result=%08x ioasc=%08x\n",
-				    __func__, scp, scp->result, cmd->sa.ioasc);
+				    __func__, scp, scp->status.combined, cmd->sa.ioasc);
 		scp->scsi_done(scp);
 	} else if (cmd->cmd_tmf) {
 		spin_lock_irqsave(&cfg->tmf_slock, lock_flags);
@@ -204,7 +204,7 @@  static void flush_pending_cmds(struct hwq *hwq)
 
 		if (cmd->scp) {
 			scp = cmd->scp;
-			scp->result = (DID_IMM_RETRY << 16);
+			scp->status.combined = (DID_IMM_RETRY << 16);
 			scp->scsi_done(scp);
 		} else {
 			cmd->cmd_aborted = true;
@@ -600,7 +600,7 @@  static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp)
 		goto out;
 	case STATE_FAILTERM:
 		dev_dbg_ratelimited(dev, "%s: device has failed\n", __func__);
-		scp->result = (DID_NO_CONNECT << 16);
+		scp->status.combined = (DID_NO_CONNECT << 16);
 		scp->scsi_done(scp);
 		rc = 0;
 		goto out;
diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c
index ee11ec340654..4a19a154e237 100644
--- a/drivers/scsi/cxlflash/superpipe.c
+++ b/drivers/scsi/cxlflash/superpipe.c
@@ -336,7 +336,7 @@  static int read_cap16(struct scsi_device *sdev, struct llun_info *lli)
 	u8 *cmd_buf = NULL;
 	u8 *scsi_cmd = NULL;
 	int rc = 0;
-	int result = 0;
+	union scsi_status result;
 	int retry_cnt = 0;
 	u32 to = CMD_TIMEOUT * HZ;
 
@@ -357,26 +357,26 @@  static int read_cap16(struct scsi_device *sdev, struct llun_info *lli)
 
 	/* Drop the ioctl read semahpore across lengthy call */
 	up_read(&cfg->ioctl_rwsem);
-	result = scsi_execute(sdev, scsi_cmd, DMA_FROM_DEVICE, cmd_buf,
+	result.combined = scsi_execute(sdev, scsi_cmd, DMA_FROM_DEVICE, cmd_buf,
 			      CMD_BUFSIZE, NULL, &sshdr, to, CMD_RETRIES,
 			      0, 0, NULL);
 	down_read(&cfg->ioctl_rwsem);
 	rc = check_state(cfg);
 	if (rc) {
 		dev_err(dev, "%s: Failed state result=%08x\n",
-			__func__, result);
+			__func__, result.combined);
 		rc = -ENODEV;
 		goto out;
 	}
 
 	if (driver_byte(result) == DRIVER_SENSE) {
-		result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */
-		if (result & SAM_STAT_CHECK_CONDITION) {
+		result.b.driver = DRIVER_OK; /* DRIVER_SENSE is not an error */
+		if (result.b.status & SAM_STAT_CHECK_CONDITION) {
 			switch (sshdr.sense_key) {
 			case NO_SENSE:
 			case RECOVERED_ERROR:
 			case NOT_READY:
-				result &= ~SAM_STAT_CHECK_CONDITION;
+				result.b.status &= ~SAM_STAT_CHECK_CONDITION;
 				break;
 			case UNIT_ATTENTION:
 				switch (sshdr.asc) {
@@ -398,9 +398,9 @@  static int read_cap16(struct scsi_device *sdev, struct llun_info *lli)
 		}
 	}
 
-	if (result) {
+	if (result.combined) {
 		dev_err(dev, "%s: command failed, result=%08x\n",
-			__func__, result);
+			__func__, result.combined);
 		rc = -EIO;
 		goto out;
 	}