Commit 9a588d23 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Martin K. Petersen

scsi: qlogicfas408: make ql_pcmd() a void function

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

[mkp: fix zeroday 'result' warning]

Link: https://lore.kernel.org/r/20210427083046.31620-21-hare@suse.deSigned-off-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>

fix
parent 5bfaafb6
...@@ -256,11 +256,10 @@ static void ql_icmd(struct scsi_cmnd *cmd) ...@@ -256,11 +256,10 @@ static void ql_icmd(struct scsi_cmnd *cmd)
* Process scsi command - usually after interrupt * 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 int i, j;
unsigned long k; unsigned long k;
unsigned int result; /* ultimate return result */
unsigned int status; /* scsi returned status */ unsigned int status; /* scsi returned status */
unsigned int message; /* scsi returned message */ unsigned int message; /* scsi returned message */
unsigned int phase; /* recorded scsi phase */ unsigned int phase; /* recorded scsi phase */
...@@ -274,13 +273,15 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd) ...@@ -274,13 +273,15 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd)
j = inb(qbase + 6); j = inb(qbase + 6);
i = inb(qbase + 5); i = inb(qbase + 5);
if (i == 0x20) { 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 */ i |= inb(qbase + 5); /* the 0x10 bit can be set after the 0x08 */
if (i != 0x18) { if (i != 0x18) {
printk(KERN_ERR "Ql:Bad Interrupt status:%02x\n", i); printk(KERN_ERR "Ql:Bad Interrupt status:%02x\n", i);
ql_zap(priv); ql_zap(priv);
return (DID_BAD_INTR << 16); set_host_byte(cmd, DID_BAD_INTR);
return;
} }
j &= 7; /* j = inb( qbase + 7 ) >> 5; */ j &= 7; /* j = inb( qbase + 7 ) >> 5; */
...@@ -293,9 +294,10 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd) ...@@ -293,9 +294,10 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd)
printk(KERN_ERR "Ql:Bad sequence for command %d, int %02X, cmdleft = %d\n", printk(KERN_ERR "Ql:Bad sequence for command %d, int %02X, cmdleft = %d\n",
j, i, inb(qbase + 7) & 0x1f); j, i, inb(qbase + 7) & 0x1f);
ql_zap(priv); 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 */ if (inb(qbase + 7) & 0x1f) /* if some bytes in fifo */
outb(1, qbase + 3); /* clear fifo */ outb(1, qbase + 3); /* clear fifo */
/* note that request_bufflen is the total xfer size when sg is used */ /* note that request_bufflen is the total xfer size when sg is used */
...@@ -314,21 +316,24 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd) ...@@ -314,21 +316,24 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd)
scsi_for_each_sg(cmd, sg, scsi_sg_count(cmd), i) { scsi_for_each_sg(cmd, sg, scsi_sg_count(cmd), i) {
if (priv->qabort) { if (priv->qabort) {
REG0; REG0;
return ((priv->qabort == 1 ? set_host_byte(cmd,
DID_ABORT : DID_RESET) << 16); priv->qabort == 1 ?
DID_ABORT : DID_RESET);
} }
buf = sg_virt(sg); buf = sg_virt(sg);
if (ql_pdma(priv, phase, buf, sg->length)) if (ql_pdma(priv, phase, buf, sg->length))
break; break;
} }
REG0; REG0;
rtrc(2) rtrc(2);
/* /*
* Wait for irq (split into second state of irq handler * Wait for irq (split into second state of irq handler
* if this can take time) * if this can take time)
*/ */
if ((k = ql_wai(priv))) if ((k = ql_wai(priv))) {
return (k << 16); set_host_byte(cmd, k);
return;
}
k = inb(qbase + 5); /* should be 0x10, bus service */ k = inb(qbase + 5); /* should be 0x10, bus service */
} }
...@@ -344,19 +349,25 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd) ...@@ -344,19 +349,25 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd)
if (time_after_eq(jiffies, k)) { if (time_after_eq(jiffies, k)) {
ql_zap(priv); ql_zap(priv);
return (DID_TIME_OUT << 16); set_host_byte(cmd, DID_TIME_OUT);
return;
} }
/* FIXME: timeout ?? */ /* FIXME: timeout ?? */
while (inb(qbase + 5)) while (inb(qbase + 5))
cpu_relax(); /* clear pending ints */ cpu_relax(); /* clear pending ints */
if (priv->qabort) if (priv->qabort) {
return ((priv->qabort == 1 ? DID_ABORT : DID_RESET) << 16); set_host_byte(cmd,
priv->qabort == 1 ? DID_ABORT : DID_RESET);
return;
}
outb(0x11, qbase + 3); /* get status and message */ outb(0x11, qbase + 3); /* get status and message */
if ((k = ql_wai(priv))) if ((k = ql_wai(priv))) {
return (k << 16); set_host_byte(cmd, k);
return;
}
i = inb(qbase + 5); /* get chip irq stat */ i = inb(qbase + 5); /* get chip irq stat */
j = inb(qbase + 7) & 0x1f; /* and bytes rec'd */ j = inb(qbase + 7) & 0x1f; /* and bytes rec'd */
status = inb(qbase + 2); status = inb(qbase + 2);
...@@ -368,12 +379,14 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd) ...@@ -368,12 +379,14 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd)
*/ */
if (!((i == 8 && j == 2) || (i == 0x10 && j == 1))) { 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); 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 */ outb(0x12, qbase + 3); /* done, disconnect */
rtrc(1) rtrc(1);
if ((k = ql_wai(priv))) if ((k = ql_wai(priv))) {
return (k << 16); set_host_byte(cmd, k);
return;
}
/* /*
* Should get bus service interrupt and disconnect interrupt * Should get bus service interrupt and disconnect interrupt
...@@ -385,12 +398,19 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd) ...@@ -385,12 +398,19 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd)
cpu_relax(); cpu_relax();
i |= inb(qbase + 5); i |= inb(qbase + 5);
} }
rtrc(0) rtrc(0);
if (priv->qabort) if (priv->qabort) {
return ((priv->qabort == 1 ? DID_ABORT : DID_RESET) << 16); set_host_byte(cmd,
priv->qabort == 1 ? DID_ABORT : DID_RESET);
return;
}
return (result << 16) | (message << 8) | (status & STATUS_MASK); set_host_byte(cmd, DID_OK);
if (message != COMMAND_COMPLETE)
scsi_msg_to_host_byte(cmd, message);
set_status_byte(cmd, status);
return;
} }
/* /*
...@@ -415,7 +435,7 @@ static void ql_ihandl(void *dev_id) ...@@ -415,7 +435,7 @@ static void ql_ihandl(void *dev_id)
return; return;
} }
icmd = priv->qlcmd; icmd = priv->qlcmd;
icmd->result = ql_pcmd(icmd); ql_pcmd(icmd);
priv->qlcmd = NULL; priv->qlcmd = NULL;
/* /*
* If result is CHECK CONDITION done calls qcommand to request * If result is CHECK CONDITION done calls qcommand to request
...@@ -443,8 +463,11 @@ static int qlogicfas408_queuecommand_lck(struct scsi_cmnd *cmd, ...@@ -443,8 +463,11 @@ static int qlogicfas408_queuecommand_lck(struct scsi_cmnd *cmd,
void (*done) (struct scsi_cmnd *)) void (*done) (struct scsi_cmnd *))
{ {
struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); 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) { if (scmd_id(cmd) == priv->qinitid) {
cmd->result = DID_BAD_TARGET << 16; set_host_byte(cmd, DID_BAD_TARGET);
done(cmd); done(cmd);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment