All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>,
	James Bottomley <james.bottomley@hansenpartnership.com>,
	linux-scsi@vger.kernel.org, Hannes Reinecke <hare@suse.de>
Subject: [PATCH 34/35] advansys: kill driver_defined status byte accessors
Date: Mon,  7 Dec 2020 13:48:18 +0100	[thread overview]
Message-ID: <20201207124819.95822-35-hare@suse.de> (raw)
In-Reply-To: <20201207124819.95822-1-hare@suse.de>

Replace the driver-defined status byte accessors by the
mid-layer defined ones.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/advansys.c | 84 ++++++++++++++-----------------------------------
 1 file changed, 24 insertions(+), 60 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 79830e77afa9..9529074c8886 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -2085,12 +2085,6 @@ do { \
 #define ASC_BUSY        0
 #define ASC_ERROR       (-1)
 
-/* struct scsi_cmnd function return codes */
-#define STATUS_BYTE(byte)   (byte)
-#define MSG_BYTE(byte)      ((byte) << 8)
-#define HOST_BYTE(byte)     ((byte) << 16)
-#define DRIVER_BYTE(byte)   ((byte) << 24)
-
 #define ASC_STATS(shost, counter) ASC_STATS_ADD(shost, counter, 1)
 #ifndef ADVANSYS_STATS
 #define ASC_STATS_ADD(shost, counter, count)
@@ -5986,10 +5980,10 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
 	/*
 	 * 'done_status' contains the command's ending status.
 	 */
+	scp->result = 0;
 	switch (scsiqp->done_status) {
 	case QD_NO_ERROR:
 		ASC_DBG(2, "QD_NO_ERROR\n");
-		scp->result = 0;
 
 		/*
 		 * Check for an underrun condition.
@@ -6010,47 +6004,33 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
 		ASC_DBG(2, "QD_WITH_ERROR\n");
 		switch (scsiqp->host_status) {
 		case QHSTA_NO_ERROR:
+			set_status_byte(scp, scsiqp->scsi_status);
 			if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
 				ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
 				ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
 						  SCSI_SENSE_BUFFERSIZE);
-				/*
-				 * Note: The 'status_byte()' macro used by
-				 * target drivers defined in scsi.h shifts the
-				 * status byte returned by host drivers right
-				 * by 1 bit.  This is why target drivers also
-				 * use right shifted status byte definitions.
-				 * For instance target drivers use
-				 * CHECK_CONDITION, defined to 0x1, instead of
-				 * the SCSI defined check condition value of
-				 * 0x2. Host drivers are supposed to return
-				 * the status byte as it is defined by SCSI.
-				 */
-				scp->result = DRIVER_BYTE(DRIVER_SENSE) |
-				    STATUS_BYTE(scsiqp->scsi_status);
-			} else {
-				scp->result = STATUS_BYTE(scsiqp->scsi_status);
+				set_driver_byte(scp, DRIVER_SENSE);
 			}
 			break;
 
 		default:
 			/* Some other QHSTA error occurred. */
 			ASC_DBG(1, "host_status 0x%x\n", scsiqp->host_status);
-			scp->result = HOST_BYTE(DID_BAD_TARGET);
+			set_host_byte(scp, DID_BAD_TARGET);
 			break;
 		}
 		break;
 
 	case QD_ABORTED_BY_HOST:
 		ASC_DBG(1, "QD_ABORTED_BY_HOST\n");
-		scp->result =
-		    HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
+		set_status_byte(scp, scsiqp->scsi_status);
+		set_host_byte(scp, DID_ABORT);
 		break;
 
 	default:
 		ASC_DBG(1, "done_status 0x%x\n", scsiqp->done_status);
-		scp->result =
-		    HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
+		set_status_byte(scp, scsiqp->scsi_status);
+		set_host_byte(scp, DID_ERROR);
 		break;
 	}
 
@@ -6752,10 +6732,10 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
 	/*
 	 * 'qdonep' contains the command's ending status.
 	 */
+	scp->result = 0;
 	switch (qdonep->d3.done_stat) {
 	case QD_NO_ERROR:
 		ASC_DBG(2, "QD_NO_ERROR\n");
-		scp->result = 0;
 
 		/*
 		 * Check for an underrun condition.
@@ -6775,51 +6755,35 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
 		ASC_DBG(2, "QD_WITH_ERROR\n");
 		switch (qdonep->d3.host_stat) {
 		case QHSTA_NO_ERROR:
+			set_status_byte(scp, qdonep->d3.scsi_stat);
 			if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
 				ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
 				ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
 						  SCSI_SENSE_BUFFERSIZE);
-				/*
-				 * Note: The 'status_byte()' macro used by
-				 * target drivers defined in scsi.h shifts the
-				 * status byte returned by host drivers right
-				 * by 1 bit.  This is why target drivers also
-				 * use right shifted status byte definitions.
-				 * For instance target drivers use
-				 * CHECK_CONDITION, defined to 0x1, instead of
-				 * the SCSI defined check condition value of
-				 * 0x2. Host drivers are supposed to return
-				 * the status byte as it is defined by SCSI.
-				 */
-				scp->result = DRIVER_BYTE(DRIVER_SENSE) |
-				    STATUS_BYTE(qdonep->d3.scsi_stat);
-			} else {
-				scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
+				set_driver_byte(scp, DRIVER_SENSE);
 			}
 			break;
 
 		default:
 			/* QHSTA error occurred */
 			ASC_DBG(1, "host_stat 0x%x\n", qdonep->d3.host_stat);
-			scp->result = HOST_BYTE(DID_BAD_TARGET);
+			set_host_byte(scp, DID_BAD_TARGET);
 			break;
 		}
 		break;
 
 	case QD_ABORTED_BY_HOST:
 		ASC_DBG(1, "QD_ABORTED_BY_HOST\n");
-		scp->result =
-		    HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.
-						    scsi_msg) |
-		    STATUS_BYTE(qdonep->d3.scsi_stat);
+		set_status_byte(scp, qdonep->d3.scsi_stat);
+		set_msg_byte(scp, qdonep->d3.scsi_msg);
+		set_host_byte(scp, DID_ABORT);
 		break;
 
 	default:
 		ASC_DBG(1, "done_stat 0x%x\n", qdonep->d3.done_stat);
-		scp->result =
-		    HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.
-						    scsi_msg) |
-		    STATUS_BYTE(qdonep->d3.scsi_stat);
+		set_status_byte(scp, qdonep->d3.scsi_stat);
+		set_msg_byte(scp, qdonep->d3.scsi_msg);
+		set_host_byte(scp, DID_ERROR);
 		break;
 	}
 
@@ -7558,7 +7522,7 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 				"sg_tablesize %d\n", use_sg,
 				scp->device->host->sg_tablesize);
 			scsi_dma_unmap(scp);
-			scp->result = HOST_BYTE(DID_ERROR);
+			set_host_byte(scp, DID_ERROR);
 			return ASC_ERROR;
 		}
 
@@ -7566,7 +7530,7 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 			use_sg * sizeof(struct asc_sg_list), GFP_ATOMIC);
 		if (!asc_sg_head) {
 			scsi_dma_unmap(scp);
-			scp->result = HOST_BYTE(DID_SOFT_ERROR);
+			set_host_byte(scp, DID_SOFT_ERROR);
 			return ASC_ERROR;
 		}
 
@@ -7809,7 +7773,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 				   "ADV_MAX_SG_LIST %d\n", use_sg,
 				   scp->device->host->sg_tablesize);
 			scsi_dma_unmap(scp);
-			scp->result = HOST_BYTE(DID_ERROR);
+			set_host_byte(scp, DID_ERROR);
 			reqp->cmndp = NULL;
 			scp->host_scribble = NULL;
 
@@ -7821,7 +7785,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 		ret = adv_get_sglist(boardp, reqp, scsiqp, scp, use_sg);
 		if (ret != ADV_SUCCESS) {
 			scsi_dma_unmap(scp);
-			scp->result = HOST_BYTE(DID_ERROR);
+			set_host_byte(scp, DID_ERROR);
 			reqp->cmndp = NULL;
 			scp->host_scribble = NULL;
 
@@ -8518,13 +8482,13 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
 		scmd_printk(KERN_ERR, scp, "ExeScsiQueue() ASC_ERROR, "
 			"err_code 0x%x\n", err_code);
 		ASC_STATS(scp->device->host, exe_error);
-		scp->result = HOST_BYTE(DID_ERROR);
+		set_host_byte(scp, DID_ERROR);
 		break;
 	default:
 		scmd_printk(KERN_ERR, scp, "ExeScsiQueue() unknown, "
 			"err_code 0x%x\n", err_code);
 		ASC_STATS(scp->device->host, exe_unknown);
-		scp->result = HOST_BYTE(DID_ERROR);
+		set_host_byte(scp, DID_ERROR);
 		break;
 	}
 
-- 
2.16.4


  parent reply	other threads:[~2020-12-07 12:50 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-07 12:47 [PATCHv3 00/35] SCSI result handling cleanup, part 1 Hannes Reinecke
2020-12-07 12:47 ` [PATCH 01/35] scsi: drop gdth driver Hannes Reinecke
2020-12-07 13:38   ` Christoph Hellwig
2020-12-07 14:01     ` Hannes Reinecke
2020-12-07 12:47 ` [PATCH 02/35] 3w-xxxx: Whitespace cleanup Hannes Reinecke
2020-12-07 12:47 ` [PATCH 03/35] 3w-9xxx: " Hannes Reinecke
2020-12-07 12:47 ` [PATCH 04/35] 3w-sas: " Hannes Reinecke
2020-12-07 12:47 ` [PATCH 05/35] atp870u: " Hannes Reinecke
2020-12-07 12:47 ` [PATCH 06/35] aic7xxx,aic79xx: " Hannes Reinecke
2020-12-07 12:47 ` [PATCH 07/35] aic7xxx,aic79xx: kill pointless forward declarations Hannes Reinecke
2020-12-07 12:47 ` [PATCH 08/35] aic7xxx,aic79xxx: remove driver-defined SAM status definitions Hannes Reinecke
2020-12-07 12:47 ` [PATCH 09/35] bfa: drop driver-defined SCSI status codes Hannes Reinecke
2020-12-07 12:47 ` [PATCH 10/35] acornscsi: use standard defines Hannes Reinecke
2020-12-07 12:47 ` [PATCH 11/35] nsp32: fixup status handling Hannes Reinecke
2020-12-07 12:47 ` [PATCH 12/35] dc395: drop private SAM status code definitions Hannes Reinecke
2020-12-07 12:47 ` [PATCH 13/35] qla4xxx: use standard SAM status definitions Hannes Reinecke
2020-12-07 12:47 ` [PATCH 14/35] zfcp: do not set COMMAND_COMPLETE Hannes Reinecke
2020-12-07 12:47 ` [PATCH 15/35] aacraid: avoid setting message byte on completion Hannes Reinecke
2020-12-07 12:48 ` [PATCH 16/35] hpsa: do not set COMMAND_COMPLETE Hannes Reinecke
2020-12-07 12:48 ` [PATCH 17/35] stex: " Hannes Reinecke
2020-12-07 12:48 ` [PATCH 18/35] nsp_cs: drop internal SCSI message definition Hannes Reinecke
2020-12-07 12:48 ` [PATCH 19/35] aic7xxx,aic79xx: " Hannes Reinecke
2020-12-07 12:48 ` [PATCH 20/35] dc395x: drop internal SCSI message definitions Hannes Reinecke
2020-12-18  8:58   ` kernel test robot
2020-12-18  8:58     ` kernel test robot
2020-12-07 12:48 ` [PATCH 21/35] initio: drop internal SCSI message definition Hannes Reinecke
2020-12-07 12:48 ` [PATCH 22/35] scsi_debug: do not set COMMAND_COMPLETE Hannes Reinecke
2020-12-07 12:48 ` [PATCH 23/35] ufshcd: " Hannes Reinecke
2020-12-07 12:48 ` [PATCH 24/35] atp870u: use standard definitions Hannes Reinecke
2020-12-07 12:48 ` [PATCH 25/35] mac53c94: Do not set invalid command result Hannes Reinecke
2020-12-07 12:48 ` [PATCH 26/35] dpt_i2o: use DID_ERROR instead of INITIATOR_ERROR message Hannes Reinecke
2020-12-07 12:48 ` [PATCH 27/35] scsi: add 'set_status_byte()' accessor Hannes Reinecke
2020-12-07 12:48 ` [PATCH 28/35] esp_scsi: use host byte as last argument to esp_cmd_is_done() Hannes Reinecke
2020-12-07 12:48 ` [PATCH 29/35] esp_scsi: do not set SCSI message byte Hannes Reinecke
2020-12-07 12:48 ` [PATCH 30/35] wd33c93: use SCSI status Hannes Reinecke
2020-12-07 12:48 ` [PATCH 31/35] ips: use correct command completion on error Hannes Reinecke
2020-12-07 12:48 ` [PATCH 32/35] storvsc: Return DID_ERROR for invalid commands Hannes Reinecke
2020-12-07 12:48 ` [PATCH 33/35] qla2xxx: fc_remote_port_chkready() returns a SCSI result value Hannes Reinecke
2020-12-07 12:48 ` Hannes Reinecke [this message]
2020-12-07 12:48 ` [PATCH 35/35] ncr53c8xx: Use SAM status values Hannes Reinecke
2021-01-13  9:04 [PATCHv4 00/35] [PATCHv3 00/35] SCSI result handling cleanup, part 1 Hannes Reinecke
2021-01-13  9:04 ` [PATCH 34/35] advansys: kill driver_defined status byte accessors Hannes Reinecke

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=20201207124819.95822-35-hare@suse.de \
    --to=hare@suse.de \
    --cc=hch@lst.de \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.