mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-20 19:23:57 +08:00
[SCSI] advansys: Restructure asc_execute_scsi_cmnd()
The wide and narrow boards share identical handling of the return value, except for some trivial error messages. Move the handling to the common end of the function. Also move variable declarations to the arms of the `if' that they're used in and delete some pointless comments. Signed-off-by: Matthew Wilcox <willy@linux.intel.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
This commit is contained in:
parent
6e8905f4a0
commit
41d2493d34
@ -11331,80 +11331,26 @@ static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
|
|||||||
*/
|
*/
|
||||||
static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
|
static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
|
||||||
{
|
{
|
||||||
asc_board_t *boardp;
|
int ret, err_code;
|
||||||
ASC_DVC_VAR *asc_dvc_varp;
|
asc_board_t *boardp = ASC_BOARDP(scp->device->host);
|
||||||
ADV_DVC_VAR *adv_dvc_varp;
|
|
||||||
ADV_SCSI_REQ_Q *adv_scsiqp;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ASC_DBG2(1, "asc_execute_scsi_cmnd: scp 0x%lx, done 0x%lx\n",
|
ASC_DBG1(1, "asc_execute_scsi_cmnd: scp 0x%p\n", scp);
|
||||||
(ulong)scp, (ulong)scp->scsi_done);
|
|
||||||
|
|
||||||
boardp = ASC_BOARDP(scp->device->host);
|
|
||||||
|
|
||||||
if (ASC_NARROW_BOARD(boardp)) {
|
if (ASC_NARROW_BOARD(boardp)) {
|
||||||
/*
|
ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
|
||||||
* Build and execute Narrow Board request.
|
|
||||||
*/
|
|
||||||
|
|
||||||
asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
|
/* asc_build_req() can not return ASC_BUSY. */
|
||||||
|
|
||||||
/*
|
|
||||||
* Build Asc Library request structure using the
|
|
||||||
* global structures 'asc_scsi_req' and 'asc_sg_head'.
|
|
||||||
*
|
|
||||||
* If an error is returned, then the request has been
|
|
||||||
* queued on the board done queue. It will be completed
|
|
||||||
* by the caller.
|
|
||||||
*
|
|
||||||
* asc_build_req() can not return ASC_BUSY.
|
|
||||||
*/
|
|
||||||
if (asc_build_req(boardp, scp) == ASC_ERROR) {
|
if (asc_build_req(boardp, scp) == ASC_ERROR) {
|
||||||
ASC_STATS(scp->device->host, build_error);
|
ASC_STATS(scp->device->host, build_error);
|
||||||
return ASC_ERROR;
|
return ASC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ret = AscExeScsiQueue(asc_dvc_varp, &asc_scsi_q)) {
|
ret = AscExeScsiQueue(asc_dvc, &asc_scsi_q);
|
||||||
case ASC_NOERROR:
|
err_code = asc_dvc->err_code;
|
||||||
ASC_STATS(scp->device->host, exe_noerror);
|
|
||||||
/*
|
|
||||||
* Increment monotonically increasing per device
|
|
||||||
* successful request counter. Wrapping doesn't matter.
|
|
||||||
*/
|
|
||||||
boardp->reqcnt[scp->device->id]++;
|
|
||||||
ASC_DBG(1, "asc_execute_scsi_cmnd: AscExeScsiQueue(), "
|
|
||||||
"ASC_NOERROR\n");
|
|
||||||
break;
|
|
||||||
case ASC_BUSY:
|
|
||||||
ASC_STATS(scp->device->host, exe_busy);
|
|
||||||
break;
|
|
||||||
case ASC_ERROR:
|
|
||||||
ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
|
|
||||||
"AscExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
|
|
||||||
boardp->id, asc_dvc_varp->err_code);
|
|
||||||
ASC_STATS(scp->device->host, exe_error);
|
|
||||||
scp->result = HOST_BYTE(DID_ERROR);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
|
|
||||||
"AscExeScsiQueue() unknown, err_code 0x%x\n",
|
|
||||||
boardp->id, asc_dvc_varp->err_code);
|
|
||||||
ASC_STATS(scp->device->host, exe_unknown);
|
|
||||||
scp->result = HOST_BYTE(DID_ERROR);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
|
||||||
* Build and execute Wide Board request.
|
ADV_SCSI_REQ_Q *adv_scsiqp;
|
||||||
*/
|
|
||||||
adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Build and get a pointer to an Adv Library request structure.
|
|
||||||
*
|
|
||||||
* If the request is successfully built then send it below,
|
|
||||||
* otherwise return with an error.
|
|
||||||
*/
|
|
||||||
switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
|
switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
|
||||||
case ASC_NOERROR:
|
case ASC_NOERROR:
|
||||||
ASC_DBG(3, "asc_execute_scsi_cmnd: adv_build_req "
|
ASC_DBG(3, "asc_execute_scsi_cmnd: adv_build_req "
|
||||||
@ -11428,35 +11374,36 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
|
|||||||
return ASC_ERROR;
|
return ASC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ret = AdvExeScsiQueue(adv_dvc_varp, adv_scsiqp)) {
|
ret = AdvExeScsiQueue(adv_dvc, adv_scsiqp);
|
||||||
case ASC_NOERROR:
|
err_code = adv_dvc->err_code;
|
||||||
ASC_STATS(scp->device->host, exe_noerror);
|
}
|
||||||
/*
|
|
||||||
* Increment monotonically increasing per device
|
switch (ret) {
|
||||||
* successful request counter. Wrapping doesn't matter.
|
case ASC_NOERROR:
|
||||||
*/
|
ASC_STATS(scp->device->host, exe_noerror);
|
||||||
boardp->reqcnt[scp->device->id]++;
|
/*
|
||||||
ASC_DBG(1, "asc_execute_scsi_cmnd: AdvExeScsiQueue(), "
|
* Increment monotonically increasing per device
|
||||||
"ASC_NOERROR\n");
|
* successful request counter. Wrapping doesn't matter.
|
||||||
break;
|
*/
|
||||||
case ASC_BUSY:
|
boardp->reqcnt[scp->device->id]++;
|
||||||
ASC_STATS(scp->device->host, exe_busy);
|
ASC_DBG(1, "asc_execute_scsi_cmnd: ExeScsiQueue(), "
|
||||||
break;
|
"ASC_NOERROR\n");
|
||||||
case ASC_ERROR:
|
break;
|
||||||
ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
|
case ASC_BUSY:
|
||||||
"AdvExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
|
ASC_STATS(scp->device->host, exe_busy);
|
||||||
boardp->id, adv_dvc_varp->err_code);
|
break;
|
||||||
ASC_STATS(scp->device->host, exe_error);
|
case ASC_ERROR:
|
||||||
scp->result = HOST_BYTE(DID_ERROR);
|
ASC_PRINT2("asc_execute_scsi_cmnd: board %d: ExeScsiQueue() "
|
||||||
break;
|
"ASC_ERROR, err_code 0x%x\n", boardp->id, err_code);
|
||||||
default:
|
ASC_STATS(scp->device->host, exe_error);
|
||||||
ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
|
scp->result = HOST_BYTE(DID_ERROR);
|
||||||
"AdvExeScsiQueue() unknown, err_code 0x%x\n",
|
break;
|
||||||
boardp->id, adv_dvc_varp->err_code);
|
default:
|
||||||
ASC_STATS(scp->device->host, exe_unknown);
|
ASC_PRINT2("asc_execute_scsi_cmnd: board %d: ExeScsiQueue() "
|
||||||
scp->result = HOST_BYTE(DID_ERROR);
|
"unknown, err_code 0x%x\n", boardp->id, err_code);
|
||||||
break;
|
ASC_STATS(scp->device->host, exe_unknown);
|
||||||
}
|
scp->result = HOST_BYTE(DID_ERROR);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASC_DBG(1, "asc_execute_scsi_cmnd: end\n");
|
ASC_DBG(1, "asc_execute_scsi_cmnd: end\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user