public inbox for linux-scsi@vger.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 24/35] atp870u: use standard definitions
Date: Wed, 13 Jan 2021 10:04:49 +0100	[thread overview]
Message-ID: <20210113090500.129644-25-hare@suse.de> (raw)
In-Reply-To: <20210113090500.129644-1-hare@suse.de>

Use standard definitions for SCSI commands and return status
instead of the hardcoded values.

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

diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c
index e559baeb0329..da6ca2b153d8 100644
--- a/drivers/scsi/atp870u.c
+++ b/drivers/scsi/atp870u.c
@@ -379,28 +379,28 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
 			if (is885(dev)) {
 				i = atp_readb_pci(dev, c, 1) & 0xf3;
 				//j=workreq->cmnd[0];
-				if ((workreq->cmnd[0] == 0x08) ||
-				    (workreq->cmnd[0] == 0x28) ||
-				    (workreq->cmnd[0] == 0x0a) ||
-				    (workreq->cmnd[0] == 0x2a)) {
+				if ((workreq->cmnd[0] == READ_6) ||
+				    (workreq->cmnd[0] == READ_10) ||
+				    (workreq->cmnd[0] == WRITE_6) ||
+				    (workreq->cmnd[0] == WRITE_10)) {
 				   i |= 0x0c;
 				}
 				atp_writeb_pci(dev, c, 1, i);
 			} else if (is880(dev)) {
-				if ((workreq->cmnd[0] == 0x08) ||
-				    (workreq->cmnd[0] == 0x28) ||
-				    (workreq->cmnd[0] == 0x0a) ||
-				    (workreq->cmnd[0] == 0x2a))
+				if ((workreq->cmnd[0] == READ_6) ||
+				    (workreq->cmnd[0] == READ_10) ||
+				    (workreq->cmnd[0] == WRITE_6) ||
+				    (workreq->cmnd[0] == WRITE_10))
 					atp_writeb_base(dev, 0x3b,
 							(atp_readb_base(dev, 0x3b) & 0x3f) | 0xc0);
 				else
 					atp_writeb_base(dev, 0x3b,
 							atp_readb_base(dev, 0x3b) & 0x3f);
 			} else {
-				if ((workreq->cmnd[0] == 0x08) ||
-				    (workreq->cmnd[0] == 0x28) ||
-				    (workreq->cmnd[0] == 0x0a) ||
-				    (workreq->cmnd[0] == 0x2a))
+				if ((workreq->cmnd[0] == READ_6) ||
+				    (workreq->cmnd[0] == READ_10) ||
+				    (workreq->cmnd[0] == WRITE_6) ||
+				    (workreq->cmnd[0] == WRITE_10))
 					atp_writeb_base(dev, 0x3a,
 							(atp_readb_base(dev, 0x3a) & 0xf3) | 0x08);
 				else
@@ -497,10 +497,10 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
 				workreq->result = atp_readb_io(dev, c, 0x0f);
 				if (((dev->r1f[c][target_id] & 0x10) != 0) && is885(dev)) {
 					printk(KERN_WARNING "AEC67162 CRC ERROR !\n");
-					workreq->result = 0x02;
+					workreq->result = SAM_STAT_CHECK_CONDITION;
 				}
 			} else
-				workreq->result = 0x02;
+				workreq->result = SAM_STAT_CHECK_CONDITION;
 
 			if (is885(dev)) {
 				j = atp_readb_base(dev, 0x29) | 0x01;
@@ -630,7 +630,7 @@ static int atp870u_queuecommand_lck(struct scsi_cmnd *req_p,
 	req_p->sense_buffer[0]=0;
 	scsi_set_resid(req_p, 0);
 	if (scmd_channel(req_p) > 1) {
-		req_p->result = 0x00040000;
+		req_p->result = DID_BAD_TARGET << 16;
 		done(req_p);
 #ifdef ED_DBGP
 		printk("atp870u_queuecommand : req_p->device->channel > 1\n");
@@ -649,7 +649,7 @@ static int atp870u_queuecommand_lck(struct scsi_cmnd *req_p,
 	 */
 
 	if ((m & dev->active_id[c]) == 0) {
-		req_p->result = 0x00040000;
+		req_p->result = DID_BAD_TARGET << 16;
 		done(req_p);
 		return 0;
 	}
@@ -684,7 +684,7 @@ static int atp870u_queuecommand_lck(struct scsi_cmnd *req_p,
 		printk("atp870u_queuecommand : dev->quhd[c] == dev->quend[c]\n");
 #endif
 		dev->quend[c]--;
-		req_p->result = 0x00020000;
+		req_p->result = DID_BUS_BUSY << 16;
 		done(req_p);
 		return 0;
 	}
@@ -800,7 +800,7 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
 		if (l > 8)
 			l = 8;
 	}
-	if (workreq->cmnd[0] == 0x00) {
+	if (workreq->cmnd[0] == TEST_UNIT_READY) {
 		l = 0;
 	}
 
@@ -934,22 +934,28 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
 	atp_writeb_pci(dev, c, 2, 0x00);
 	if (is885(dev)) {
 		j = atp_readb_pci(dev, c, 1) & 0xf3;
-		if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) ||
-		    (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a)) {
+		if ((workreq->cmnd[0] == READ_6) ||
+		    (workreq->cmnd[0] == READ_10) ||
+		    (workreq->cmnd[0] == WRITE_6) ||
+		    (workreq->cmnd[0] == WRITE_10)) {
 			j |= 0x0c;
 		}
 		atp_writeb_pci(dev, c, 1, j);
 	} else if (is880(dev)) {
-		if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) ||
-		    (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a))
+		if ((workreq->cmnd[0] == READ_6) ||
+		    (workreq->cmnd[0] == READ_10) ||
+		    (workreq->cmnd[0] == WRITE_6) ||
+		    (workreq->cmnd[0] == WRITE_10))
 			atp_writeb_base(dev, 0x3b,
 					(atp_readb_base(dev, 0x3b) & 0x3f) | 0xc0);
 		else
 			atp_writeb_base(dev, 0x3b,
 					atp_readb_base(dev, 0x3b) & 0x3f);
 	} else {
-		if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) ||
-		    (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a))
+		if ((workreq->cmnd[0] == READ_6) ||
+		    (workreq->cmnd[0] == READ_10) ||
+		    (workreq->cmnd[0] == WRITE_6) ||
+		    (workreq->cmnd[0] == WRITE_10))
 			atp_writeb_base(dev, 0x3a,
 					(atp_readb_base(dev, 0x3a) & 0xf3) | 0x08);
 		else
-- 
2.29.2


  parent reply	other threads:[~2021-01-13  9:07 UTC|newest]

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