[SCSI] NCR5380: Use scsi_eh API for REQUEST_SENSE invocation
authorBoaz Harrosh <bharrosh@panasas.com>
Mon, 10 Sep 2007 19:37:45 +0000 (22:37 +0300)
committerJames Bottomley <jejb@mulgrave.localdomain>
Fri, 12 Oct 2007 18:55:07 +0000 (14:55 -0400)
  - Use new scsi_eh_prep/restor_cmnd() for synchronous
    REQUEST_SENSE invocation.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/NCR5380.c
drivers/scsi/NCR5380.h
drivers/scsi/atari_NCR5380.c
drivers/scsi/sun3_NCR5380.c

index 5b27966d37f03096489e98533019ec641f480113..988f0bc5eda5e081929864f40f87fbf4e0b49f75 100644 (file)
@@ -1542,9 +1542,7 @@ part2:
        hostdata->connected = cmd;
        hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);
 
-       if (cmd->SCp.ptr != (char *)cmd->sense_buffer) {
-               initialize_SCp(cmd);
-       }
+       initialize_SCp(cmd);
 
        return 0;
 
@@ -2280,19 +2278,16 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) {
                                                cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);
 
 #ifdef AUTOSENSE
+                                       if ((cmd->cmnd[0] == REQUEST_SENSE) &&
+                                               hostdata->ses.cmd_len) {
+                                               scsi_eh_restore_cmnd(cmd, &hostdata->ses);
+                                               hostdata->ses.cmd_len = 0 ;
+                                       }
+
                                        if ((cmd->cmnd[0] != REQUEST_SENSE) && (status_byte(cmd->SCp.Status) == CHECK_CONDITION)) {
+                                               scsi_eh_prep_cmnd(cmd, &hostdata->ses, NULL, 0, ~0);
+
                                                dprintk(NDEBUG_AUTOSENSE, ("scsi%d : performing request sense\n", instance->host_no));
-                                               cmd->cmnd[0] = REQUEST_SENSE;
-                                               cmd->cmnd[1] &= 0xe0;
-                                               cmd->cmnd[2] = 0;
-                                               cmd->cmnd[3] = 0;
-                                               cmd->cmnd[4] = sizeof(cmd->sense_buffer);
-                                               cmd->cmnd[5] = 0;
-
-                                               cmd->SCp.buffer = NULL;
-                                               cmd->SCp.buffers_residual = 0;
-                                               cmd->SCp.ptr = (char *) cmd->sense_buffer;
-                                               cmd->SCp.this_residual = sizeof(cmd->sense_buffer);
 
                                                LIST(cmd, hostdata->issue_queue);
                                                cmd->host_scribble = (unsigned char *)
index bccf13f715321a9daaaf82cac1a50d6b868646a8..bdc468c9e1d9d6de71ba091041096fd831512ee7 100644 (file)
 
 #include <linux/interrupt.h>
 
+#ifdef AUTOSENSE
+#include <scsi/scsi_eh.h>
+#endif
+
 #define NCR5380_PUBLIC_RELEASE 7
 #define NCR53C400_PUBLIC_RELEASE 2
 
@@ -281,6 +285,9 @@ struct NCR5380_hostdata {
        unsigned pendingr;
        unsigned pendingw;
 #endif
+#ifdef AUTOSENSE
+       struct scsi_eh_save ses;
+#endif
 };
 
 #ifdef __KERNEL__
index 743df4c20cf419389aa4d5b5220de98b00240f11..52d0b87e9aa48f06cabb7c86ea6fff4b9b23ede0 100644 (file)
@@ -2235,24 +2235,17 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
                                                cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);
 
 #ifdef AUTOSENSE
+                                       if ((cmd->cmnd[0] == REQUEST_SENSE) &&
+                                               hostdata->ses.cmd_len) {
+                                               scsi_eh_restore_cmnd(cmd, &hostdata->ses);
+                                               hostdata->ses.cmd_len = 0 ;
+                                       }
+
                                        if ((cmd->cmnd[0] != REQUEST_SENSE) &&
                                            (status_byte(cmd->SCp.Status) == CHECK_CONDITION)) {
+                                               scsi_eh_prep_cmnd(cmd, &hostdata->ses, NULL, 0, ~0);
+
                                                ASEN_PRINTK("scsi%d: performing request sense\n", HOSTNO);
-                                               cmd->cmnd[0] = REQUEST_SENSE;
-                                               cmd->cmnd[1] &= 0xe0;
-                                               cmd->cmnd[2] = 0;
-                                               cmd->cmnd[3] = 0;
-                                               cmd->cmnd[4] = sizeof(cmd->sense_buffer);
-                                               cmd->cmnd[5] = 0;
-                                               cmd->cmd_len = COMMAND_SIZE(cmd->cmnd[0]);
-
-                                               cmd->use_sg = 0;
-                                               /* this is initialized from initialize_SCp
-                                               cmd->SCp.buffer = NULL;
-                                               cmd->SCp.buffers_residual = 0;
-                                               */
-                                               cmd->request_buffer = (char *) cmd->sense_buffer;
-                                               cmd->request_bufflen = sizeof(cmd->sense_buffer);
 
                                                local_irq_save(flags);
                                                LIST(cmd,hostdata->issue_queue);
index 376953776ea363524f9ae4a1e626164f2b258004..dc15a22105f71ac6102cd4b63e5b60c2ab4ca3ef 100644 (file)
@@ -2254,25 +2254,21 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
                        cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);
                    
 #ifdef AUTOSENSE
+                   if ((cmd->cmnd[0] == REQUEST_SENSE) &&
+                                               hostdata->ses.cmd_len) {
+                       scsi_eh_restore_cmnd(cmd, &hostdata->ses);
+                       hostdata->ses.cmd_len = 0 ;
+                   }
+
                    if ((cmd->cmnd[0] != REQUEST_SENSE) && 
                        (status_byte(cmd->SCp.Status) == CHECK_CONDITION)) {
+                       scsi_eh_prep_cmnd(cmd, &hostdata->ses, NULL, 0, ~0);
                        ASEN_PRINTK("scsi%d: performing request sense\n",
                                    HOSTNO);
-                       cmd->cmnd[0] = REQUEST_SENSE;
-                       cmd->cmnd[1] &= 0xe0;
-                       cmd->cmnd[2] = 0;
-                       cmd->cmnd[3] = 0;
-                       cmd->cmnd[4] = sizeof(cmd->sense_buffer);
-                       cmd->cmnd[5] = 0;
-                       cmd->cmd_len = COMMAND_SIZE(cmd->cmnd[0]);
-
-                       cmd->use_sg = 0;
                        /* this is initialized from initialize_SCp 
                        cmd->SCp.buffer = NULL;
                        cmd->SCp.buffers_residual = 0;
                        */
-                       cmd->request_buffer = (char *) cmd->sense_buffer;
-                       cmd->request_bufflen = sizeof(cmd->sense_buffer);
 
                        local_irq_save(flags);
                        LIST(cmd,hostdata->issue_queue);