]> err.no Git - linux-2.6/commitdiff
[SCSI] advansys: Restructure asc_execute_scsi_cmnd()
authorMatthew Wilcox <matthew@wil.cx>
Wed, 3 Oct 2007 01:55:24 +0000 (21:55 -0400)
committerJames Bottomley <jejb@mulgrave.localdomain>
Fri, 12 Oct 2007 18:52:59 +0000 (14:52 -0400)
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>
drivers/scsi/advansys.c

index 737c0e4b3190393d439c462e0782954212151185..3dd785617602df6ac911e6471d98b459a358169e 100644 (file)
@@ -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");