]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/scsi_error.c
V4L/DVB (3425): Correct gpio values for Aver 303 Studio in v4l-dvb tree
[linux-2.6-omap-h63xx.git] / drivers / scsi / scsi_error.c
index 18c5d252301441b287735e74b0dfae07c48b75af..ff82ccfbb106b528539e112168a1aba8d250294c 100644 (file)
@@ -422,10 +422,15 @@ static int scsi_eh_completed_normally(struct scsi_cmnd *scmd)
  **/
 static void scsi_eh_done(struct scsi_cmnd *scmd)
 {
+       struct completion     *eh_action;
+
        SCSI_LOG_ERROR_RECOVERY(3,
                printk("%s scmd: %p result: %x\n",
                        __FUNCTION__, scmd, scmd->result));
-       complete(scmd->device->host->eh_action);
+
+       eh_action = scmd->device->host->eh_action;
+       if (eh_action)
+               complete(eh_action);
 }
 
 /**
@@ -1303,7 +1308,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
         * the request was not marked fast fail.  Note that above,
         * even if the request is marked fast fail, we still requeue
         * for queue congestion conditions (QUEUE_FULL or BUSY) */
-       if ((++scmd->retries) < scmd->allowed 
+       if ((++scmd->retries) <= scmd->allowed
            && !blk_noretry_request(scmd->request)) {
                return NEEDS_RETRY;
        } else {
@@ -1314,23 +1319,6 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
        }
 }
 
-/**
- * scsi_eh_lock_done - done function for eh door lock request
- * @scmd:      SCSI command block for the door lock request
- *
- * Notes:
- *     We completed the asynchronous door lock request, and it has either
- *     locked the door or failed.  We must free the command structures
- *     associated with this request.
- **/
-static void scsi_eh_lock_done(struct scsi_cmnd *scmd)
-{
-       struct scsi_request *sreq = scmd->sc_request;
-
-       scsi_release_request(sreq);
-}
-
-
 /**
  * scsi_eh_lock_door - Prevent medium removal for the specified device
  * @sdev:      SCSI device to prevent medium removal
@@ -1353,29 +1341,17 @@ static void scsi_eh_lock_done(struct scsi_cmnd *scmd)
  **/
 static void scsi_eh_lock_door(struct scsi_device *sdev)
 {
-       struct scsi_request *sreq = scsi_allocate_request(sdev, GFP_KERNEL);
+       unsigned char cmnd[MAX_COMMAND_SIZE];
 
-       if (unlikely(!sreq)) {
-               printk(KERN_ERR "%s: request allocate failed,"
-                      "prevent media removal cmd not sent\n", __FUNCTION__);
-               return;
-       }
+       cmnd[0] = ALLOW_MEDIUM_REMOVAL;
+       cmnd[1] = 0;
+       cmnd[2] = 0;
+       cmnd[3] = 0;
+       cmnd[4] = SCSI_REMOVAL_PREVENT;
+       cmnd[5] = 0;
 
-       sreq->sr_cmnd[0] = ALLOW_MEDIUM_REMOVAL;
-       sreq->sr_cmnd[1] = 0;
-       sreq->sr_cmnd[2] = 0;
-       sreq->sr_cmnd[3] = 0;
-       sreq->sr_cmnd[4] = SCSI_REMOVAL_PREVENT;
-       sreq->sr_cmnd[5] = 0;
-       sreq->sr_data_direction = DMA_NONE;
-       sreq->sr_bufflen = 0;
-       sreq->sr_buffer = NULL;
-       sreq->sr_allowed = 5;
-       sreq->sr_done = scsi_eh_lock_done;
-       sreq->sr_timeout_per_command = 10 * HZ;
-       sreq->sr_cmd_len = COMMAND_SIZE(sreq->sr_cmnd[0]);
-
-       scsi_insert_special_req(sreq, 1);
+       scsi_execute_async(sdev, cmnd, 6, DMA_NONE, NULL, 0, 0, 10 * HZ,
+                          5, NULL, NULL, GFP_KERNEL);
 }
 
 
@@ -1457,7 +1433,7 @@ static void scsi_eh_flush_done_q(struct list_head *done_q)
                list_del_init(&scmd->eh_entry);
                if (scsi_device_online(scmd->device) &&
                    !blk_noretry_request(scmd->request) &&
-                   (++scmd->retries < scmd->allowed)) {
+                   (++scmd->retries <= scmd->allowed)) {
                        SCSI_LOG_ERROR_RECOVERY(3, printk("%s: flush"
                                                          " retry cmd: %p\n",
                                                          current->comm,