aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2007-10-02 21:55:24 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-12 14:52:59 -0400
commit41d2493d3478942f891b21dff60951ff939c08d9 (patch)
tree755abed809d87450700e69d4003f50307ad92a0a /drivers
parent6e8905f4a028bd07190fa5b2f90b5a35868c84d8 (diff)
[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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/advansys.c131
1 files changed, 39 insertions, 92 deletions
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 737c0e4b319..3dd78561760 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -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)
{
- asc_board_t *boardp;
- ASC_DVC_VAR *asc_dvc_varp;
- ADV_DVC_VAR *adv_dvc_varp;
- ADV_SCSI_REQ_Q *adv_scsiqp;
- int ret;
+ int ret, err_code;
+ asc_board_t *boardp = ASC_BOARDP(scp->device->host);
- ASC_DBG2(1, "asc_execute_scsi_cmnd: scp 0x%lx, done 0x%lx\n",
- (ulong)scp, (ulong)scp->scsi_done);
-
- boardp = ASC_BOARDP(scp->device->host);
+ ASC_DBG1(1, "asc_execute_scsi_cmnd: scp 0x%p\n", scp);
if (ASC_NARROW_BOARD(boardp)) {
- /*
- * Build and execute Narrow Board request.
- */
-
- asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
+ ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
- /*
- * 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.
- */
+ /* asc_build_req() can not return ASC_BUSY. */
if (asc_build_req(boardp, scp) == ASC_ERROR) {
ASC_STATS(scp->device->host, build_error);
return ASC_ERROR;
}
- switch (ret = AscExeScsiQueue(asc_dvc_varp, &asc_scsi_q)) {
- case ASC_NOERROR:
- 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;
- }
+ ret = AscExeScsiQueue(asc_dvc, &asc_scsi_q);
+ err_code = asc_dvc->err_code;
} else {
- /*
- * Build and execute Wide Board request.
- */
- adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
+ ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
+ ADV_SCSI_REQ_Q *adv_scsiqp;
- /*
- * 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)) {
case ASC_NOERROR:
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;
}
- switch (ret = AdvExeScsiQueue(adv_dvc_varp, adv_scsiqp)) {
- case ASC_NOERROR:
- 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: AdvExeScsiQueue(), "
- "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: "
- "AdvExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
- boardp->id, adv_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: "
- "AdvExeScsiQueue() unknown, err_code 0x%x\n",
- boardp->id, adv_dvc_varp->err_code);
- ASC_STATS(scp->device->host, exe_unknown);
- scp->result = HOST_BYTE(DID_ERROR);
- break;
- }
+ ret = AdvExeScsiQueue(adv_dvc, adv_scsiqp);
+ err_code = adv_dvc->err_code;
+ }
+
+ switch (ret) {
+ case ASC_NOERROR:
+ 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: ExeScsiQueue(), "
+ "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: ExeScsiQueue() "
+ "ASC_ERROR, err_code 0x%x\n", boardp->id, 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: ExeScsiQueue() "
+ "unknown, err_code 0x%x\n", boardp->id, err_code);
+ ASC_STATS(scp->device->host, exe_unknown);
+ scp->result = HOST_BYTE(DID_ERROR);
+ break;
}
ASC_DBG(1, "asc_execute_scsi_cmnd: end\n");