diff mbox series

[19/39] qlogicfas408: make ql_pcmd() a void function

Message ID 20210423113944.42672-20-hare@suse.de
State New
Headers show
Series SCSI result cleanup, part 2 | expand

Commit Message

Hannes Reinecke April 23, 2021, 11:39 a.m. UTC
Make ql_pcmd() a void function and set the SCSI result directly.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/qlogicfas408.c | 75 ++++++++++++++++++++++++-------------
 1 file changed, 49 insertions(+), 26 deletions(-)

Comments

Christoph Hellwig April 26, 2021, 3:26 p.m. UTC | #1
On Fri, Apr 23, 2021 at 01:39:24PM +0200, Hannes Reinecke wrote:
> Make ql_pcmd() a void function and set the SCSI result directly.

> 

> Signed-off-by: Hannes Reinecke <hare@suse.de>

> ---

>  drivers/scsi/qlogicfas408.c | 75 ++++++++++++++++++++++++-------------

>  1 file changed, 49 insertions(+), 26 deletions(-)


Can you explain why this is useful?  Because it does not really look
like it cleans up anything as-is.
Hannes Reinecke April 26, 2021, 3:45 p.m. UTC | #2
On 4/26/21 5:26 PM, Christoph Hellwig wrote:
> On Fri, Apr 23, 2021 at 01:39:24PM +0200, Hannes Reinecke wrote:

>> Make ql_pcmd() a void function and set the SCSI result directly.

>>

>> Signed-off-by: Hannes Reinecke <hare@suse.de>

>> ---

>>  drivers/scsi/qlogicfas408.c | 75 ++++++++++++++++++++++++-------------

>>  1 file changed, 49 insertions(+), 26 deletions(-)

> 

> Can you explain why this is useful?  Because it does not really look

> like it cleans up anything as-is.

> 

Hmm. I needed it for the entire patchset (splitting up host_byte and
status_byte in two distinct values), but it might well be pointless here.
Will be checking it and dropping if not required.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		        Kernel Storage Architect
hare@suse.de			               +49 911 74053 688
SUSE Software Solutions Germany GmbH, 90409 Nürnberg
GF: F. Imendörffer, HRB 36809 (AG Nürnberg)
Hannes Reinecke April 27, 2021, 7:36 a.m. UTC | #3
On 4/26/21 5:26 PM, Christoph Hellwig wrote:
> On Fri, Apr 23, 2021 at 01:39:24PM +0200, Hannes Reinecke wrote:

>> Make ql_pcmd() a void function and set the SCSI result directly.

>>

>> Signed-off-by: Hannes Reinecke <hare@suse.de>

>> ---

>>   drivers/scsi/qlogicfas408.c | 75 ++++++++++++++++++++++++-------------

>>   1 file changed, 49 insertions(+), 26 deletions(-)

> 

> Can you explain why this is useful?  Because it does not really look

> like it cleans up anything as-is.

> 

It doesn't cleanup per-se, but it allows us to use the SCSI result 
accessor functions to set the final result.
Without it we'll have to construct the result as a numeric value
within ql_pcmd(), and then set that value as a result to the SCSI 
command in the caller.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
diff mbox series

Patch

diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c
index 136681ad18a5..a1eabdc7db09 100644
--- a/drivers/scsi/qlogicfas408.c
+++ b/drivers/scsi/qlogicfas408.c
@@ -256,7 +256,7 @@  static void ql_icmd(struct scsi_cmnd *cmd)
  *	Process scsi command - usually after interrupt 
  */
 
-static unsigned int ql_pcmd(struct scsi_cmnd *cmd)
+static void ql_pcmd(struct scsi_cmnd *cmd)
 {
 	unsigned int i, j;
 	unsigned long k;
@@ -274,13 +274,15 @@  static unsigned int ql_pcmd(struct scsi_cmnd *cmd)
 	j = inb(qbase + 6);
 	i = inb(qbase + 5);
 	if (i == 0x20) {
-		return (DID_NO_CONNECT << 16);
+		set_host_byte(cmd, DID_NO_CONNECT);
+		return;
 	}
 	i |= inb(qbase + 5);	/* the 0x10 bit can be set after the 0x08 */
 	if (i != 0x18) {
 		printk(KERN_ERR "Ql:Bad Interrupt status:%02x\n", i);
 		ql_zap(priv);
-		return (DID_BAD_INTR << 16);
+		set_host_byte(cmd, DID_BAD_INTR);
+		return;
 	}
 	j &= 7;			/* j = inb( qbase + 7 ) >> 5; */
 
@@ -293,9 +295,10 @@  static unsigned int ql_pcmd(struct scsi_cmnd *cmd)
 		printk(KERN_ERR "Ql:Bad sequence for command %d, int %02X, cmdleft = %d\n",
 		     j, i, inb(qbase + 7) & 0x1f);
 		ql_zap(priv);
-		return (DID_ERROR << 16);
+		set_host_byte (cmd, DID_ERROR);
+		return;
 	}
-	result = DID_OK;
+
 	if (inb(qbase + 7) & 0x1f)	/* if some bytes in fifo */
 		outb(1, qbase + 3);	/* clear fifo */
 	/* note that request_bufflen is the total xfer size when sg is used */
@@ -314,21 +317,24 @@  static unsigned int ql_pcmd(struct scsi_cmnd *cmd)
 		scsi_for_each_sg(cmd, sg, scsi_sg_count(cmd), i) {
 			if (priv->qabort) {
 				REG0;
-				return ((priv->qabort == 1 ?
-					 DID_ABORT : DID_RESET) << 16);
+				set_host_byte(cmd,
+					      priv->qabort == 1 ?
+					      DID_ABORT : DID_RESET);
 			}
 			buf = sg_virt(sg);
 			if (ql_pdma(priv, phase, buf, sg->length))
 				break;
 		}
 		REG0;
-		rtrc(2)
+		rtrc(2);
 		/*
 		 *	Wait for irq (split into second state of irq handler
 		 *	if this can take time) 
 		 */
-		if ((k = ql_wai(priv)))
-			return (k << 16);
+		if ((k = ql_wai(priv))) {
+			set_host_byte(cmd, k);
+			return;
+		}
 		k = inb(qbase + 5);	/* should be 0x10, bus service */
 	}
 
@@ -344,19 +350,25 @@  static unsigned int ql_pcmd(struct scsi_cmnd *cmd)
 
 	if (time_after_eq(jiffies, k)) {
 		ql_zap(priv);
-		return (DID_TIME_OUT << 16);
+		set_host_byte(cmd, DID_TIME_OUT);
+		return;
 	}
 
 	/* FIXME: timeout ?? */
 	while (inb(qbase + 5))
 		cpu_relax();	/* clear pending ints */
 
-	if (priv->qabort)
-		return ((priv->qabort == 1 ? DID_ABORT : DID_RESET) << 16);
+	if (priv->qabort) {
+		set_host_byte(cmd,
+			      priv->qabort == 1 ? DID_ABORT : DID_RESET);
+		return;
+	}
 
 	outb(0x11, qbase + 3);	/* get status and message */
-	if ((k = ql_wai(priv)))
-		return (k << 16);
+	if ((k = ql_wai(priv))) {
+		set_host_byte(cmd, k);
+		return;
+	}
 	i = inb(qbase + 5);	/* get chip irq stat */
 	j = inb(qbase + 7) & 0x1f;	/* and bytes rec'd */
 	status = inb(qbase + 2);
@@ -368,12 +380,14 @@  static unsigned int ql_pcmd(struct scsi_cmnd *cmd)
 	 */
 	if (!((i == 8 && j == 2) || (i == 0x10 && j == 1))) {
 		printk(KERN_ERR "Ql:Error during status phase, int=%02X, %d bytes recd\n", i, j);
-		result = DID_ERROR;
+		set_host_byte(cmd, DID_ERROR);
 	}
 	outb(0x12, qbase + 3);	/* done, disconnect */
-	rtrc(1)
-	if ((k = ql_wai(priv)))
-		return (k << 16);
+	rtrc(1);
+	if ((k = ql_wai(priv))) {
+		set_host_byte(cmd, k);
+		return;
+	}
 
 	/*
 	 *	Should get bus service interrupt and disconnect interrupt 
@@ -385,12 +399,18 @@  static unsigned int ql_pcmd(struct scsi_cmnd *cmd)
 		cpu_relax();
 		i |= inb(qbase + 5);
 	}
-	rtrc(0)
+	rtrc(0);
 
-	if (priv->qabort)
-		return ((priv->qabort == 1 ? DID_ABORT : DID_RESET) << 16);
-		
-	return (result << 16) | (message << 8) | (status & STATUS_MASK);
+	if (priv->qabort) {
+		set_host_byte(cmd,
+			      priv->qabort == 1 ? DID_ABORT : DID_RESET);
+		return;
+	}
+
+	set_host_byte(cmd, result);
+	set_msg_byte(cmd, message);
+	set_status_byte(cmd, status);
+	return;
 }
 
 /*
@@ -415,7 +435,7 @@  static void ql_ihandl(void *dev_id)
 		return;
 	}
 	icmd = priv->qlcmd;
-	icmd->result = ql_pcmd(icmd);
+	ql_pcmd(icmd);
 	priv->qlcmd = NULL;
 	/*
 	 *	If result is CHECK CONDITION done calls qcommand to request 
@@ -443,8 +463,11 @@  static int qlogicfas408_queuecommand_lck(struct scsi_cmnd *cmd,
 			      void (*done) (struct scsi_cmnd *))
 {
 	struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);
+
+	set_host_byte(cmd, DID_OK);
+	set_status_byte(cmd, SAM_STAT_GOOD);
 	if (scmd_id(cmd) == priv->qinitid) {
-		cmd->result = DID_BAD_TARGET << 16;
+		set_host_byte(cmd, DID_BAD_TARGET);
 		done(cmd);
 		return 0;
 	}