linux-scsi.vger.kernel.org archive mirror
 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 11/24] advansys: kill driver_defined status byte accessors
Date: Thu, 31 Oct 2019 12:04:39 +0100	[thread overview]
Message-ID: <20191031110452.73463-12-hare@suse.de> (raw)
In-Reply-To: <20191031110452.73463-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>
---
 drivers/scsi/advansys.c | 78 +++++++++++++------------------------------------
 1 file changed, 20 insertions(+), 58 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index a242a62caaa1..5268b4b92e43 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)
@@ -6021,43 +6015,28 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
 				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);
 			}
+			scp->result = status_byte(scsiqp->scsi_status);
 			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);
+			scp->result = host_byte(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);
+		scp->result = host_byte(DID_ABORT);
+		set_status_byte(scp, scsiqp->scsi_status);
 		break;
 
 	default:
 		ASC_DBG(1, "done_status 0x%x\n", scsiqp->done_status);
-		scp->result =
-		    HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
+		scp->result = host_byte(DID_ERROR);
+		set_status_byte(scp, scsiqp->scsi_status);
 		break;
 	}
 
@@ -6789,47 +6768,30 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
 				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);
 			}
+			scp->result = status_byte(qdonep->d3.scsi_stat);
 			break;
 
 		default:
 			/* QHSTA error occurred */
 			ASC_DBG(1, "host_stat 0x%x\n", qdonep->d3.host_stat);
-			scp->result = HOST_BYTE(DID_BAD_TARGET);
+			scp->result = host_byte(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);
+		scp->result = host_byte(DID_ABORT);
+		set_msg_byte(scp, qdonep->d3.scsi_msg);
+		set_status_byte(scp, qdonep->d3.scsi_stat);
 		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);
+		scp->result = host_byte(DID_ERROR);
+		set_msg_byte(scp, qdonep->d3.scsi_msg);
+		set_status_byte(scp, qdonep->d3.scsi_stat);
 		break;
 	}
 
@@ -7568,7 +7530,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);
+			scp->result = host_byte(DID_ERROR);
 			return ASC_ERROR;
 		}
 
@@ -7576,7 +7538,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);
+			scp->result = host_byte(DID_SOFT_ERROR);
 			return ASC_ERROR;
 		}
 
@@ -7819,7 +7781,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);
+			scp->result = host_byte(DID_ERROR);
 			reqp->cmndp = NULL;
 			scp->host_scribble = NULL;
 
@@ -7831,7 +7793,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);
+			scp->result = host_byte(DID_ERROR);
 			reqp->cmndp = NULL;
 			scp->host_scribble = NULL;
 
@@ -8528,13 +8490,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);
+		scp->result = host_byte(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);
+		scp->result = host_byte(DID_ERROR);
 		break;
 	}
 
-- 
2.16.4


  parent reply	other threads:[~2019-10-31 11:05 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-31 11:04 [PATCHv2 00/24] Revamp SCSI result values Hannes Reinecke
2019-10-31 11:04 ` [PATCH 01/24] aic7xxx,aic79xxx: remove driver-defined SAM status definitions Hannes Reinecke
2019-11-01 16:14   ` Bart Van Assche
2019-10-31 11:04 ` [PATCH 02/24] bfa: drop driver-defined SCSI status codes Hannes Reinecke
2019-11-01 16:15   ` Bart Van Assche
2019-10-31 11:04 ` [PATCH 03/24] wd33c93: use SCSI status Hannes Reinecke
2019-11-01 16:16   ` Bart Van Assche
2019-10-31 11:04 ` [PATCH 04/24] acornscsi: use standard defines Hannes Reinecke
2019-11-01 16:18   ` Bart Van Assche
2019-11-01 16:40     ` Hannes Reinecke
2019-10-31 11:04 ` [PATCH 05/24] scsi: use standard SAM status codes Hannes Reinecke
2019-11-01 16:26   ` Bart Van Assche
2019-11-01 16:54     ` Hannes Reinecke
2019-11-01 18:10       ` Bart Van Assche
2019-10-31 11:04 ` [PATCH 06/24] scsi: change status_byte() to return the standard SCSI status Hannes Reinecke
2019-10-31 11:04 ` [PATCH 07/24] target_core: Fixup target_complete_cmd() usage Hannes Reinecke
2019-11-01 16:29   ` Bart Van Assche
2019-10-31 11:04 ` [PATCH 08/24] sg: use SAM status definitions and avoid using masked_status Hannes Reinecke
2019-10-31 11:04 ` [PATCH 09/24] scsi: Kill obsolete linux-specific status codes Hannes Reinecke
2019-11-02 13:14   ` kbuild test robot
2019-10-31 11:04 ` [PATCH 10/24] scsi: introduce set_status_byte() Hannes Reinecke
2019-11-01 16:36   ` Bart Van Assche
2019-10-31 11:04 ` Hannes Reinecke [this message]
2019-10-31 11:04 ` [PATCH 12/24] scsi: introduce scsi_build_sense() Hannes Reinecke
2019-11-01 16:35   ` Bart Van Assche
2019-10-31 11:04 ` [PATCH 13/24] scsi: Kill DRIVER_SENSE Hannes Reinecke
2019-10-31 11:04 ` [PATCH 14/24] scsi: Kill DRIVER_HARD Hannes Reinecke
2019-10-31 11:04 ` [PATCH 15/24] scsi_error: use DID_TIME_OUT instead of DRIVER_TIMEOUT Hannes Reinecke
2019-10-31 11:04 ` [PATCH 16/24] scsi: Kill DRIVER_TIMEOUT Hannes Reinecke
2019-10-31 11:04 ` [PATCH 17/24] scsi: do not use DRIVER_INVALID Hannes Reinecke
2019-11-02  3:28   ` Finn Thain
2019-10-31 11:04 ` [PATCH 18/24] st: return error code in st_scsi_execute() Hannes Reinecke
2019-10-31 11:04 ` [PATCH 19/24] scsi_ioctl: return error code when blk_rq_map_kern() fails Hannes Reinecke
2019-10-31 11:04 ` [PATCH 20/24] scsi_dh_alua: do not interpret DRIVER_ERROR Hannes Reinecke
2019-10-31 11:04 ` [PATCH 21/24] xen-scsiback: stop using DRIVER_ERROR Hannes Reinecke
2019-10-31 11:04 ` [PATCH 22/24] scsi: " Hannes Reinecke
2019-10-31 11:04 ` [PATCH 23/24] scsi: Kill DRIVER_MEDIA, DRIVER_SOFT, and DRIVER_BUSY Hannes Reinecke
2019-10-31 11:04 ` [PATCH 24/24] scsi: Drop the now obsolete driver_byte definitions Hannes Reinecke
  -- strict thread matches above, loose matches on Subject: below --
2019-10-21  9:52 [PATCH RFC 00/24] scsi: Revamp result values Hannes Reinecke
2019-10-21  9:53 ` [PATCH 11/24] advansys: kill driver_defined status byte accessors Hannes Reinecke
2019-10-21 16:37   ` Bart Van Assche
2019-10-22  6:25     ` 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=20191031110452.73463-12-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 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).