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

scsi: advansys: Kill driver-defined status byte accessors

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

Link: https://lore.kernel.org/r/20210113090500.129644-35-hare@suse.deReviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 6098c300
...@@ -2085,12 +2085,6 @@ do { \ ...@@ -2085,12 +2085,6 @@ do { \
#define ASC_BUSY 0 #define ASC_BUSY 0
#define ASC_ERROR (-1) #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) #define ASC_STATS(shost, counter) ASC_STATS_ADD(shost, counter, 1)
#ifndef ADVANSYS_STATS #ifndef ADVANSYS_STATS
#define ASC_STATS_ADD(shost, counter, count) #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) ...@@ -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. * 'done_status' contains the command's ending status.
*/ */
scp->result = 0;
switch (scsiqp->done_status) { switch (scsiqp->done_status) {
case QD_NO_ERROR: case QD_NO_ERROR:
ASC_DBG(2, "QD_NO_ERROR\n"); ASC_DBG(2, "QD_NO_ERROR\n");
scp->result = 0;
/* /*
* Check for an underrun condition. * 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) ...@@ -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"); ASC_DBG(2, "QD_WITH_ERROR\n");
switch (scsiqp->host_status) { switch (scsiqp->host_status) {
case QHSTA_NO_ERROR: case QHSTA_NO_ERROR:
set_status_byte(scp, scsiqp->scsi_status);
if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) { if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n"); ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
ASC_DBG_PRT_SENSE(2, scp->sense_buffer, ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
SCSI_SENSE_BUFFERSIZE); SCSI_SENSE_BUFFERSIZE);
/* set_driver_byte(scp, DRIVER_SENSE);
* 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);
} }
break; break;
default: default:
/* Some other QHSTA error occurred. */ /* Some other QHSTA error occurred. */
ASC_DBG(1, "host_status 0x%x\n", scsiqp->host_status); 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;
} }
break; break;
case QD_ABORTED_BY_HOST: case QD_ABORTED_BY_HOST:
ASC_DBG(1, "QD_ABORTED_BY_HOST\n"); ASC_DBG(1, "QD_ABORTED_BY_HOST\n");
scp->result = set_status_byte(scp, scsiqp->scsi_status);
HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status); set_host_byte(scp, DID_ABORT);
break; break;
default: default:
ASC_DBG(1, "done_status 0x%x\n", scsiqp->done_status); ASC_DBG(1, "done_status 0x%x\n", scsiqp->done_status);
scp->result = set_status_byte(scp, scsiqp->scsi_status);
HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status); set_host_byte(scp, DID_ERROR);
break; break;
} }
...@@ -6752,10 +6732,10 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep) ...@@ -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. * 'qdonep' contains the command's ending status.
*/ */
scp->result = 0;
switch (qdonep->d3.done_stat) { switch (qdonep->d3.done_stat) {
case QD_NO_ERROR: case QD_NO_ERROR:
ASC_DBG(2, "QD_NO_ERROR\n"); ASC_DBG(2, "QD_NO_ERROR\n");
scp->result = 0;
/* /*
* Check for an underrun condition. * Check for an underrun condition.
...@@ -6775,51 +6755,35 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep) ...@@ -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"); ASC_DBG(2, "QD_WITH_ERROR\n");
switch (qdonep->d3.host_stat) { switch (qdonep->d3.host_stat) {
case QHSTA_NO_ERROR: case QHSTA_NO_ERROR:
set_status_byte(scp, qdonep->d3.scsi_stat);
if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) { if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n"); ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
ASC_DBG_PRT_SENSE(2, scp->sense_buffer, ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
SCSI_SENSE_BUFFERSIZE); SCSI_SENSE_BUFFERSIZE);
/* set_driver_byte(scp, DRIVER_SENSE);
* 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);
} }
break; break;
default: default:
/* QHSTA error occurred */ /* QHSTA error occurred */
ASC_DBG(1, "host_stat 0x%x\n", qdonep->d3.host_stat); 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;
} }
break; break;
case QD_ABORTED_BY_HOST: case QD_ABORTED_BY_HOST:
ASC_DBG(1, "QD_ABORTED_BY_HOST\n"); ASC_DBG(1, "QD_ABORTED_BY_HOST\n");
scp->result = set_status_byte(scp, qdonep->d3.scsi_stat);
HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3. set_msg_byte(scp, qdonep->d3.scsi_msg);
scsi_msg) | set_host_byte(scp, DID_ABORT);
STATUS_BYTE(qdonep->d3.scsi_stat);
break; break;
default: default:
ASC_DBG(1, "done_stat 0x%x\n", qdonep->d3.done_stat); ASC_DBG(1, "done_stat 0x%x\n", qdonep->d3.done_stat);
scp->result = set_status_byte(scp, qdonep->d3.scsi_stat);
HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3. set_msg_byte(scp, qdonep->d3.scsi_msg);
scsi_msg) | set_host_byte(scp, DID_ERROR);
STATUS_BYTE(qdonep->d3.scsi_stat);
break; break;
} }
...@@ -7558,7 +7522,7 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, ...@@ -7558,7 +7522,7 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
"sg_tablesize %d\n", use_sg, "sg_tablesize %d\n", use_sg,
scp->device->host->sg_tablesize); scp->device->host->sg_tablesize);
scsi_dma_unmap(scp); scsi_dma_unmap(scp);
scp->result = HOST_BYTE(DID_ERROR); set_host_byte(scp, DID_ERROR);
return ASC_ERROR; return ASC_ERROR;
} }
...@@ -7566,7 +7530,7 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, ...@@ -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); use_sg * sizeof(struct asc_sg_list), GFP_ATOMIC);
if (!asc_sg_head) { if (!asc_sg_head) {
scsi_dma_unmap(scp); scsi_dma_unmap(scp);
scp->result = HOST_BYTE(DID_SOFT_ERROR); set_host_byte(scp, DID_SOFT_ERROR);
return ASC_ERROR; return ASC_ERROR;
} }
...@@ -7809,7 +7773,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, ...@@ -7809,7 +7773,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
"ADV_MAX_SG_LIST %d\n", use_sg, "ADV_MAX_SG_LIST %d\n", use_sg,
scp->device->host->sg_tablesize); scp->device->host->sg_tablesize);
scsi_dma_unmap(scp); scsi_dma_unmap(scp);
scp->result = HOST_BYTE(DID_ERROR); set_host_byte(scp, DID_ERROR);
reqp->cmndp = NULL; reqp->cmndp = NULL;
scp->host_scribble = NULL; scp->host_scribble = NULL;
...@@ -7821,7 +7785,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, ...@@ -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); ret = adv_get_sglist(boardp, reqp, scsiqp, scp, use_sg);
if (ret != ADV_SUCCESS) { if (ret != ADV_SUCCESS) {
scsi_dma_unmap(scp); scsi_dma_unmap(scp);
scp->result = HOST_BYTE(DID_ERROR); set_host_byte(scp, DID_ERROR);
reqp->cmndp = NULL; reqp->cmndp = NULL;
scp->host_scribble = NULL; scp->host_scribble = NULL;
...@@ -8518,13 +8482,13 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp) ...@@ -8518,13 +8482,13 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
scmd_printk(KERN_ERR, scp, "ExeScsiQueue() ASC_ERROR, " scmd_printk(KERN_ERR, scp, "ExeScsiQueue() ASC_ERROR, "
"err_code 0x%x\n", err_code); "err_code 0x%x\n", err_code);
ASC_STATS(scp->device->host, exe_error); ASC_STATS(scp->device->host, exe_error);
scp->result = HOST_BYTE(DID_ERROR); set_host_byte(scp, DID_ERROR);
break; break;
default: default:
scmd_printk(KERN_ERR, scp, "ExeScsiQueue() unknown, " scmd_printk(KERN_ERR, scp, "ExeScsiQueue() unknown, "
"err_code 0x%x\n", err_code); "err_code 0x%x\n", err_code);
ASC_STATS(scp->device->host, exe_unknown); ASC_STATS(scp->device->host, exe_unknown);
scp->result = HOST_BYTE(DID_ERROR); set_host_byte(scp, DID_ERROR);
break; break;
} }
......
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