[SG] Update drivers to use sg helpers
[safe/jmp/linux-2.6] / drivers / scsi / aacraid / aachba.c
index 2dbfbe3..a77ab8d 100644 (file)
@@ -169,6 +169,18 @@ int acbsize = -1;
 module_param(acbsize, int, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(acbsize, "Request a specific adapter control block (FIB) size. Valid values are 512, 2048, 4096 and 8192. Default is to use suggestion from Firmware.");
 
+int update_interval = 30 * 60;
+module_param(update_interval, int, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(update_interval, "Interval in seconds between time sync updates issued to adapter.");
+
+int check_interval = 24 * 60 * 60;
+module_param(check_interval, int, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(check_interval, "Interval in seconds between adapter health checks.");
+
+int aac_check_reset = 1;
+module_param_named(check_reset, aac_check_reset, int, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(aac_check_reset, "If adapter fails health check, reset the adapter.");
+
 int expose_physicals = -1;
 module_param(expose_physicals, int, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(expose_physicals, "Expose physical components of the arrays. -1=protect 0=off, 1=on");
@@ -182,8 +194,7 @@ static inline int aac_valid_context(struct scsi_cmnd *scsicmd,
        struct scsi_device *device;
 
        if (unlikely(!scsicmd || !scsicmd->scsi_done )) {
-               dprintk((KERN_WARNING "aac_valid_context: scsi command corrupt\n"))
-;
+               dprintk((KERN_WARNING "aac_valid_context: scsi command corrupt\n"));
                 aac_fib_complete(fibptr);
                 aac_fib_free(fibptr);
                 return 0;
@@ -312,11 +323,10 @@ int aac_get_containers(struct aac_dev *dev)
 
        if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS)
                maximum_num_containers = MAXIMUM_NUM_CONTAINERS;
-       fsa_dev_ptr =  kmalloc(sizeof(*fsa_dev_ptr) * maximum_num_containers,
+       fsa_dev_ptr = kzalloc(sizeof(*fsa_dev_ptr) * maximum_num_containers,
                        GFP_KERNEL);
        if (!fsa_dev_ptr)
                return -ENOMEM;
-       memset(fsa_dev_ptr, 0, sizeof(*fsa_dev_ptr) * maximum_num_containers);
 
        dev->fsa_dev = fsa_dev_ptr;
        dev->maximum_num_containers = maximum_num_containers;
@@ -346,7 +356,7 @@ static void aac_internal_transfer(struct scsi_cmnd *scsicmd, void *data, unsigne
        int transfer_len;
        struct scatterlist *sg = scsi_sglist(scsicmd);
 
-       buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset;
+       buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
        transfer_len = min(sg->length, len + offset);
 
        transfer_len -= offset;
@@ -446,7 +456,7 @@ static int aac_probe_container_callback2(struct scsi_cmnd * scsicmd)
 {
        struct fsa_dev_info *fsa_dev_ptr = ((struct aac_dev *)(scsicmd->device->host->hostdata))->fsa_dev;
 
-       if (fsa_dev_ptr[scmd_id(scsicmd)].valid)
+       if ((fsa_dev_ptr[scmd_id(scsicmd)].valid & 1))
                return aac_scsi_cmd(scsicmd);
 
        scsicmd->result = DID_NO_CONNECT << 16;
@@ -454,18 +464,18 @@ static int aac_probe_container_callback2(struct scsi_cmnd * scsicmd)
        return 0;
 }
 
-static int _aac_probe_container2(void * context, struct fib * fibptr)
+static void _aac_probe_container2(void * context, struct fib * fibptr)
 {
        struct fsa_dev_info *fsa_dev_ptr;
        int (*callback)(struct scsi_cmnd *);
        struct scsi_cmnd * scsicmd = (struct scsi_cmnd *)context;
 
-       if (!aac_valid_context(scsicmd, fibptr))
-               return 0;
 
-       fsa_dev_ptr = ((struct aac_dev *)(scsicmd->device->host->hostdata))->fsa_dev;
+       if (!aac_valid_context(scsicmd, fibptr))
+               return;
 
        scsicmd->SCp.Status = 0;
+       fsa_dev_ptr = fibptr->dev->fsa_dev;
        if (fsa_dev_ptr) {
                struct aac_mount * dresp = (struct aac_mount *) fib_data(fibptr);
                fsa_dev_ptr += scmd_id(scsicmd);
@@ -488,10 +498,11 @@ static int _aac_probe_container2(void * context, struct fib * fibptr)
        aac_fib_free(fibptr);
        callback = (int (*)(struct scsi_cmnd *))(scsicmd->SCp.ptr);
        scsicmd->SCp.ptr = NULL;
-       return (*callback)(scsicmd);
+       (*callback)(scsicmd);
+       return;
 }
 
-static int _aac_probe_container1(void * context, struct fib * fibptr)
+static void _aac_probe_container1(void * context, struct fib * fibptr)
 {
        struct scsi_cmnd * scsicmd;
        struct aac_mount * dresp;
@@ -501,13 +512,14 @@ static int _aac_probe_container1(void * context, struct fib * fibptr)
        dresp = (struct aac_mount *) fib_data(fibptr);
        dresp->mnt[0].capacityhigh = 0;
        if ((le32_to_cpu(dresp->status) != ST_OK) ||
-           (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE))
-               return _aac_probe_container2(context, fibptr);
+           (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE)) {
+               _aac_probe_container2(context, fibptr);
+               return;
+       }
        scsicmd = (struct scsi_cmnd *) context;
-       scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL;
 
        if (!aac_valid_context(scsicmd, fibptr))
-               return 0;
+               return;
 
        aac_fib_init(fibptr);
 
@@ -522,21 +534,18 @@ static int _aac_probe_container1(void * context, struct fib * fibptr)
                          sizeof(struct aac_query_mount),
                          FsaNormal,
                          0, 1,
-                         (fib_callback) _aac_probe_container2,
+                         _aac_probe_container2,
                          (void *) scsicmd);
        /*
         *      Check that the command queued to the controller
         */
-       if (status == -EINPROGRESS) {
+       if (status == -EINPROGRESS)
                scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
-               return 0;
-       }
-       if (status < 0) {
+       else if (status < 0) {
                /* Inherit results from VM_NameServe, if any */
                dresp->status = cpu_to_le32(ST_OK);
-               return _aac_probe_container2(context, fibptr);
+               _aac_probe_container2(context, fibptr);
        }
-       return 0;
 }
 
 static int _aac_probe_container(struct scsi_cmnd * scsicmd, int (*callback)(struct scsi_cmnd *))
@@ -561,7 +570,7 @@ static int _aac_probe_container(struct scsi_cmnd * scsicmd, int (*callback)(stru
                          sizeof(struct aac_query_mount),
                          FsaNormal,
                          0, 1,
-                         (fib_callback) _aac_probe_container1,
+                         _aac_probe_container1,
                          (void *) scsicmd);
                /*
                 *      Check that the command queued to the controller
@@ -615,7 +624,7 @@ int aac_probe_container(struct aac_dev *dev, int cid)
                return -ENOMEM;
        }
        scsicmd->list.next = NULL;
-       scsicmd->scsi_done = (void (*)(struct scsi_cmnd*))_aac_probe_container1;
+       scsicmd->scsi_done = (void (*)(struct scsi_cmnd*))aac_probe_container_callback1;
 
        scsicmd->device = scsidev;
        scsidev->sdev_state = 0;
@@ -741,6 +750,101 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex)
        inqstrcpy ("V1.0", str->prl);
 }
 
+static void get_container_serial_callback(void *context, struct fib * fibptr)
+{
+       struct aac_get_serial_resp * get_serial_reply;
+       struct scsi_cmnd * scsicmd;
+
+       BUG_ON(fibptr == NULL);
+
+       scsicmd = (struct scsi_cmnd *) context;
+       if (!aac_valid_context(scsicmd, fibptr))
+               return;
+
+       get_serial_reply = (struct aac_get_serial_resp *) fib_data(fibptr);
+       /* Failure is irrelevant, using default value instead */
+       if (le32_to_cpu(get_serial_reply->status) == CT_OK) {
+               char sp[13];
+               /* EVPD bit set */
+               sp[0] = INQD_PDT_DA;
+               sp[1] = scsicmd->cmnd[2];
+               sp[2] = 0;
+               sp[3] = snprintf(sp+4, sizeof(sp)-4, "%08X",
+                 le32_to_cpu(get_serial_reply->uid));
+               aac_internal_transfer(scsicmd, sp, 0, sizeof(sp));
+       }
+
+       scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
+
+       aac_fib_complete(fibptr);
+       aac_fib_free(fibptr);
+       scsicmd->scsi_done(scsicmd);
+}
+
+/**
+ *     aac_get_container_serial - get container serial, none blocking.
+ */
+static int aac_get_container_serial(struct scsi_cmnd * scsicmd)
+{
+       int status;
+       struct aac_get_serial *dinfo;
+       struct fib * cmd_fibcontext;
+       struct aac_dev * dev;
+
+       dev = (struct aac_dev *)scsicmd->device->host->hostdata;
+
+       if (!(cmd_fibcontext = aac_fib_alloc(dev)))
+               return -ENOMEM;
+
+       aac_fib_init(cmd_fibcontext);
+       dinfo = (struct aac_get_serial *) fib_data(cmd_fibcontext);
+
+       dinfo->command = cpu_to_le32(VM_ContainerConfig);
+       dinfo->type = cpu_to_le32(CT_CID_TO_32BITS_UID);
+       dinfo->cid = cpu_to_le32(scmd_id(scsicmd));
+
+       status = aac_fib_send(ContainerCommand,
+                 cmd_fibcontext,
+                 sizeof (struct aac_get_serial),
+                 FsaNormal,
+                 0, 1,
+                 (fib_callback) get_container_serial_callback,
+                 (void *) scsicmd);
+
+       /*
+        *      Check that the command queued to the controller
+        */
+       if (status == -EINPROGRESS) {
+               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
+               return 0;
+       }
+
+       printk(KERN_WARNING "aac_get_container_serial: aac_fib_send failed with status: %d.\n", status);
+       aac_fib_complete(cmd_fibcontext);
+       aac_fib_free(cmd_fibcontext);
+       return -1;
+}
+
+/* Function: setinqserial
+ *
+ * Arguments: [1] pointer to void [1] int
+ *
+ * Purpose: Sets SCSI Unit Serial number.
+ *          This is a fake. We should read a proper
+ *          serial number from the container. <SuSE>But
+ *          without docs it's quite hard to do it :-)
+ *          So this will have to do in the meantime.</SuSE>
+ */
+
+static int setinqserial(struct aac_dev *dev, void *data, int cid)
+{
+       /*
+        *      This breaks array migration.
+        */
+       return snprintf((char *)(data), sizeof(struct scsi_inq) - 4, "%08X%02X",
+                       le32_to_cpu(dev->adapter_info.serial[0]), cid);
+}
+
 static void set_sense(u8 *sense_buf, u8 sense_key, u8 sense_code,
                      u8 a_sense_code, u8 incorrect_length,
                      u8 bit_pointer, u16 field_pointer,
@@ -1169,6 +1273,7 @@ int aac_get_adapter_info(struct aac_dev* dev)
        }
 
        if (!dev->in_reset) {
+               char buffer[16];
                tmp = le32_to_cpu(dev->adapter_info.kernelrev);
                printk(KERN_INFO "%s%d: kernel %d.%d-%d[%d] %.*s\n",
                        dev->name, 
@@ -1189,16 +1294,23 @@ int aac_get_adapter_info(struct aac_dev* dev)
                        dev->name, dev->id,
                        tmp>>24,(tmp>>16)&0xff,tmp&0xff,
                        le32_to_cpu(dev->adapter_info.biosbuild));
-               if (le32_to_cpu(dev->adapter_info.serial[0]) != 0xBAD0)
-                       printk(KERN_INFO "%s%d: serial %x\n",
-                               dev->name, dev->id,
-                               le32_to_cpu(dev->adapter_info.serial[0]));
+               buffer[0] = '\0';
+               if (aac_show_serial_number(
+                 shost_to_class(dev->scsi_host_ptr), buffer))
+                       printk(KERN_INFO "%s%d: serial %s",
+                         dev->name, dev->id, buffer);
                if (dev->supplement_adapter_info.VpdInfo.Tsid[0]) {
                        printk(KERN_INFO "%s%d: TSID %.*s\n",
                          dev->name, dev->id,
                          (int)sizeof(dev->supplement_adapter_info.VpdInfo.Tsid),
                          dev->supplement_adapter_info.VpdInfo.Tsid);
                }
+               if (!aac_check_reset ||
+                 (dev->supplement_adapter_info.SupportedOptions2 &
+                 le32_to_cpu(AAC_OPTION_IGNORE_RESET))) {
+                       printk(KERN_INFO "%s%d: Reset Adapter Ignored\n",
+                         dev->name, dev->id);
+               }
        }
 
        dev->nondasd_support = 0;
@@ -1329,7 +1441,7 @@ static void io_callback(void *context, struct fib * fibptr)
        if (!aac_valid_context(scsicmd, fibptr))
                return;
 
-       dev = (struct aac_dev *)scsicmd->device->host->hostdata;
+       dev = fibptr->dev;
        cid = scmd_id(scsicmd);
 
        if (nblank(dprintk(x))) {
@@ -1576,23 +1688,23 @@ static void synchronize_callback(void *context, struct fib *fibptr)
        if (!aac_valid_context(cmd, fibptr))
                return;
 
-       dprintk((KERN_DEBUG "synchronize_callback[cpu %d]: t = %ld.\n", 
+       dprintk((KERN_DEBUG "synchronize_callback[cpu %d]: t = %ld.\n",
                                smp_processor_id(), jiffies));
        BUG_ON(fibptr == NULL);
 
 
        synchronizereply = fib_data(fibptr);
        if (le32_to_cpu(synchronizereply->status) == CT_OK)
-               cmd->result = DID_OK << 16 | 
+               cmd->result = DID_OK << 16 |
                        COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
        else {
                struct scsi_device *sdev = cmd->device;
-               struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata;
+               struct aac_dev *dev = fibptr->dev;
                u32 cid = sdev_id(sdev);
-               printk(KERN_WARNING 
+               printk(KERN_WARNING
                     "synchronize_callback: synchronize failed, status = %d\n",
                     le32_to_cpu(synchronizereply->status));
-               cmd->result = DID_OK << 16 | 
+               cmd->result = DID_OK << 16 |
                        COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
                set_sense((u8 *)&dev->fsa_dev[cid].sense_data,
                                    HARDWARE_ERROR,
@@ -1600,7 +1712,7 @@ static void synchronize_callback(void *context, struct fib *fibptr)
                                    ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
                                    0, 0);
                memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
-                 min(sizeof(dev->fsa_dev[cid].sense_data), 
+                 min(sizeof(dev->fsa_dev[cid].sense_data),
                          sizeof(cmd->sense_buffer)));
        }
 
@@ -1618,6 +1730,9 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
        struct scsi_device *sdev = scsicmd->device;
        int active = 0;
        struct aac_dev *aac;
+       u64 lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) |
+               (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
+       u32 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
        unsigned long flags;
 
        /*
@@ -1626,7 +1741,51 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
         */
        spin_lock_irqsave(&sdev->list_lock, flags);
        list_for_each_entry(cmd, &sdev->cmd_list, list)
-               if (cmd != scsicmd && cmd->SCp.phase == AAC_OWNER_FIRMWARE) {
+               if (cmd->SCp.phase == AAC_OWNER_FIRMWARE) {
+                       u64 cmnd_lba;
+                       u32 cmnd_count;
+
+                       if (cmd->cmnd[0] == WRITE_6) {
+                               cmnd_lba = ((cmd->cmnd[1] & 0x1F) << 16) |
+                                       (cmd->cmnd[2] << 8) |
+                                       cmd->cmnd[3];
+                               cmnd_count = cmd->cmnd[4];
+                               if (cmnd_count == 0)
+                                       cmnd_count = 256;
+                       } else if (cmd->cmnd[0] == WRITE_16) {
+                               cmnd_lba = ((u64)cmd->cmnd[2] << 56) |
+                                       ((u64)cmd->cmnd[3] << 48) |
+                                       ((u64)cmd->cmnd[4] << 40) |
+                                       ((u64)cmd->cmnd[5] << 32) |
+                                       ((u64)cmd->cmnd[6] << 24) |
+                                       (cmd->cmnd[7] << 16) |
+                                       (cmd->cmnd[8] << 8) |
+                                       cmd->cmnd[9];
+                               cmnd_count = (cmd->cmnd[10] << 24) |
+                                       (cmd->cmnd[11] << 16) |
+                                       (cmd->cmnd[12] << 8) |
+                                       cmd->cmnd[13];
+                       } else if (cmd->cmnd[0] == WRITE_12) {
+                               cmnd_lba = ((u64)cmd->cmnd[2] << 24) |
+                                       (cmd->cmnd[3] << 16) |
+                                       (cmd->cmnd[4] << 8) |
+                                       cmd->cmnd[5];
+                               cmnd_count = (cmd->cmnd[6] << 24) |
+                                       (cmd->cmnd[7] << 16) |
+                                       (cmd->cmnd[8] << 8) |
+                                       cmd->cmnd[9];
+                       } else if (cmd->cmnd[0] == WRITE_10) {
+                               cmnd_lba = ((u64)cmd->cmnd[2] << 24) |
+                                       (cmd->cmnd[3] << 16) |
+                                       (cmd->cmnd[4] << 8) |
+                                       cmd->cmnd[5];
+                               cmnd_count = (cmd->cmnd[7] << 8) |
+                                       cmd->cmnd[8];
+                       } else
+                               continue;
+                       if (((cmnd_lba + cmnd_count) < lba) ||
+                         (count && ((lba + count) < cmnd_lba)))
+                               continue;
                        ++active;
                        break;
                }
@@ -1655,7 +1814,7 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
        synchronizecmd->command = cpu_to_le32(VM_ContainerConfig);
        synchronizecmd->type = cpu_to_le32(CT_FLUSH_CACHE);
        synchronizecmd->cid = cpu_to_le32(scmd_id(scsicmd));
-       synchronizecmd->count = 
+       synchronizecmd->count =
             cpu_to_le32(sizeof(((struct aac_synchronize_reply *)NULL)->data));
 
        /*
@@ -1677,7 +1836,7 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
                return 0;
        }
 
-       printk(KERN_WARNING 
+       printk(KERN_WARNING
                "aac_synchronize: aac_fib_send failed with status: %d.\n", status);
        aac_fib_complete(cmd_fibcontext);
        aac_fib_free(cmd_fibcontext);
@@ -1694,7 +1853,7 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
  
 int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
 {
-       u32 cid = 0;
+       u32 cid;
        struct Scsi_Host *host = scsicmd->device->host;
        struct aac_dev *dev = (struct aac_dev *)host->hostdata;
        struct fsa_dev_info *fsa_dev_ptr = dev->fsa_dev;
@@ -1706,15 +1865,15 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
         *      Test does not apply to ID 16, the pseudo id for the controller
         *      itself.
         */
-       if (scmd_id(scsicmd) != host->this_id) {
-               if ((scmd_channel(scsicmd) == CONTAINER_CHANNEL)) {
-                       if((scmd_id(scsicmd) >= dev->maximum_num_containers) ||
+       cid = scmd_id(scsicmd);
+       if (cid != host->this_id) {
+               if (scmd_channel(scsicmd) == CONTAINER_CHANNEL) {
+                       if((cid >= dev->maximum_num_containers) ||
                                        (scsicmd->device->lun != 0)) {
                                scsicmd->result = DID_NO_CONNECT << 16;
                                scsicmd->scsi_done(scsicmd);
                                return 0;
                        }
-                       cid = scmd_id(scsicmd);
 
                        /*
                         *      If the target container doesn't exist, it may have
@@ -1777,9 +1936,52 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
        {
                struct inquiry_data inq_data;
 
-               dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", scmd_id(scsicmd)));
+               dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", cid));
                memset(&inq_data, 0, sizeof (struct inquiry_data));
 
+               if (scsicmd->cmnd[1] & 0x1 ) {
+                       char *arr = (char *)&inq_data;
+
+                       /* EVPD bit set */
+                       arr[0] = (scmd_id(scsicmd) == host->this_id) ?
+                         INQD_PDT_PROC : INQD_PDT_DA;
+                       if (scsicmd->cmnd[2] == 0) {
+                               /* supported vital product data pages */
+                               arr[3] = 2;
+                               arr[4] = 0x0;
+                               arr[5] = 0x80;
+                               arr[1] = scsicmd->cmnd[2];
+                               aac_internal_transfer(scsicmd, &inq_data, 0,
+                                 sizeof(inq_data));
+                               scsicmd->result = DID_OK << 16 |
+                                 COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
+                       } else if (scsicmd->cmnd[2] == 0x80) {
+                               /* unit serial number page */
+                               arr[3] = setinqserial(dev, &arr[4],
+                                 scmd_id(scsicmd));
+                               arr[1] = scsicmd->cmnd[2];
+                               aac_internal_transfer(scsicmd, &inq_data, 0,
+                                 sizeof(inq_data));
+                               return aac_get_container_serial(scsicmd);
+                       } else {
+                               /* vpd page not implemented */
+                               scsicmd->result = DID_OK << 16 |
+                                 COMMAND_COMPLETE << 8 |
+                                 SAM_STAT_CHECK_CONDITION;
+                               set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
+                                 ILLEGAL_REQUEST,
+                                 SENCODE_INVALID_CDB_FIELD,
+                                 ASENCODE_NO_SENSE, 0, 7, 2, 0);
+                               memcpy(scsicmd->sense_buffer,
+                                 &dev->fsa_dev[cid].sense_data,
+                                 (sizeof(dev->fsa_dev[cid].sense_data) >
+                                   sizeof(scsicmd->sense_buffer))
+                                      ? sizeof(scsicmd->sense_buffer)
+                                      : sizeof(dev->fsa_dev[cid].sense_data));
+                       }
+                       scsicmd->scsi_done(scsicmd);
+                       return 0;
+               }
                inq_data.inqd_ver = 2;  /* claim compliance to SCSI-2 */
                inq_data.inqd_rdf = 2;  /* A response data format value of two indicates that the data shall be in the format specified in SCSI-2 */
                inq_data.inqd_len = 31;
@@ -1789,7 +1991,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
                 *      Set the Vendor, Product, and Revision Level
                 *      see: <vendor>.c i.e. aac.c
                 */
-               if (scmd_id(scsicmd) == host->this_id) {
+               if (cid == host->this_id) {
                        setinqstr(dev, (void *) (inq_data.inqd_vid), ARRAY_SIZE(container_types));
                        inq_data.inqd_pdt = INQD_PDT_PROC;      /* Processor device */
                        aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data));
@@ -2052,7 +2254,7 @@ static int query_disk(struct aac_dev *dev, void __user *arg)
        }
        else return -EINVAL;
 
-       qd.valid = fsa_dev_ptr[qd.cnum].valid;
+       qd.valid = fsa_dev_ptr[qd.cnum].valid != 0;
        qd.locked = fsa_dev_ptr[qd.cnum].locked;
        qd.deleted = fsa_dev_ptr[qd.cnum].deleted;
 
@@ -2160,10 +2362,10 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
        if (!aac_valid_context(scsicmd, fibptr))
                return;
 
-       dev = (struct aac_dev *)scsicmd->device->host->hostdata;
-
        BUG_ON(fibptr == NULL);
 
+       dev = fibptr->dev;
+
        srbreply = (struct aac_srb_reply *) fib_data(fibptr);
 
        scsicmd->sense_buffer[0] = '\0';  /* Initialize sense valid flag to false */
@@ -2250,7 +2452,7 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
                break;
 
        case SRB_STATUS_BUSY:
-               scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8;
+               scsicmd->result = DID_BUS_BUSY << 16 | COMMAND_COMPLETE << 8;
                break;
 
        case SRB_STATUS_BUS_RESET: