scsi: aacraid: remove redundant setting of variable c
[pandora-kernel.git] / drivers / scsi / aacraid / aachba.c
index 409f580..29ffc65 100644 (file)
@@ -468,6 +468,7 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd)
 
        aac_fib_init(cmd_fibcontext);
        dinfo = (struct aac_get_name *) fib_data(cmd_fibcontext);
+       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
 
        dinfo->command = cpu_to_le32(VM_ContainerConfig);
        dinfo->type = cpu_to_le32(CT_READ_NAME);
@@ -485,10 +486,8 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd)
        /*
         *      Check that the command queued to the controller
         */
-       if (status == -EINPROGRESS) {
-               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
+       if (status == -EINPROGRESS)
                return 0;
-       }
 
        printk(KERN_WARNING "aac_get_container_name: aac_fib_send failed with status: %d.\n", status);
        aac_fib_complete(cmd_fibcontext);
@@ -577,6 +576,7 @@ static void _aac_probe_container1(void * context, struct fib * fibptr)
        dinfo->command = cpu_to_le32(VM_NameServe64);
        dinfo->count = cpu_to_le32(scmd_id(scsicmd));
        dinfo->type = cpu_to_le32(FT_FILESYS);
+       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
 
        status = aac_fib_send(ContainerCommand,
                          fibptr,
@@ -588,9 +588,7 @@ static void _aac_probe_container1(void * context, struct fib * fibptr)
        /*
         *      Check that the command queued to the controller
         */
-       if (status == -EINPROGRESS)
-               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
-       else if (status < 0) {
+       if (status < 0 && status != -EINPROGRESS) {
                /* Inherit results from VM_NameServe, if any */
                dresp->status = cpu_to_le32(ST_OK);
                _aac_probe_container2(context, fibptr);
@@ -613,6 +611,7 @@ static int _aac_probe_container(struct scsi_cmnd * scsicmd, int (*callback)(stru
                dinfo->count = cpu_to_le32(scmd_id(scsicmd));
                dinfo->type = cpu_to_le32(FT_FILESYS);
                scsicmd->SCp.ptr = (char *)callback;
+               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
 
                status = aac_fib_send(ContainerCommand,
                          fibptr,
@@ -624,10 +623,9 @@ static int _aac_probe_container(struct scsi_cmnd * scsicmd, int (*callback)(stru
                /*
                 *      Check that the command queued to the controller
                 */
-               if (status == -EINPROGRESS) {
-                       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
+               if (status == -EINPROGRESS)
                        return 0;
-               }
+
                if (status < 0) {
                        scsicmd->SCp.ptr = NULL;
                        aac_fib_complete(fibptr);
@@ -760,8 +758,16 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex)
        memset(str, ' ', sizeof(*str));
 
        if (dev->supplement_adapter_info.AdapterTypeText[0]) {
-               char * cp = dev->supplement_adapter_info.AdapterTypeText;
                int c;
+               char *cp;
+               char *cname = kmemdup(dev->supplement_adapter_info.AdapterTypeText,
+                               sizeof(dev->supplement_adapter_info.AdapterTypeText),
+                                                               GFP_ATOMIC);
+
+               if (!cname)
+                       return;
+
+               cp = cname;
                if ((cp[0] == 'A') && (cp[1] == 'O') && (cp[2] == 'C'))
                        inqstrcpy("SMC", str->vid);
                else {
@@ -770,8 +776,7 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex)
                                ++cp;
                        c = *cp;
                        *cp = '\0';
-                       inqstrcpy (dev->supplement_adapter_info.AdapterTypeText,
-                                  str->vid);
+                       inqstrcpy(cname, str->vid);
                        *cp = c;
                        while (*cp && *cp != ' ')
                                ++cp;
@@ -779,14 +784,11 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex)
                while (*cp == ' ')
                        ++cp;
                /* last six chars reserved for vol type */
-               c = 0;
-               if (strlen(cp) > sizeof(str->pid)) {
-                       c = cp[sizeof(str->pid)];
+               if (strlen(cp) > sizeof(str->pid))
                        cp[sizeof(str->pid)] = '\0';
-               }
                inqstrcpy (cp, str->pid);
-               if (c)
-                       cp[sizeof(str->pid)] = c;
+
+               kfree(cname);
        } else {
                struct aac_driver_ident *mp = aac_get_driver_ident(dev->cardtype);
 
@@ -861,6 +863,7 @@ static int aac_get_container_serial(struct scsi_cmnd * scsicmd)
        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));
+       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
 
        status = aac_fib_send(ContainerCommand,
                  cmd_fibcontext,
@@ -873,10 +876,8 @@ static int aac_get_container_serial(struct scsi_cmnd * scsicmd)
        /*
         *      Check that the command queued to the controller
         */
-       if (status == -EINPROGRESS) {
-               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
+       if (status == -EINPROGRESS)
                return 0;
-       }
 
        printk(KERN_WARNING "aac_get_container_serial: aac_fib_send failed with status: %d.\n", status);
        aac_fib_complete(cmd_fibcontext);
@@ -1689,16 +1690,14 @@ static int aac_read(struct scsi_cmnd * scsicmd)
                printk(KERN_WARNING "aac_read: fib allocation failed\n");
                return -1;
        }
-
+       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
        status = aac_adapter_read(cmd_fibcontext, scsicmd, lba, count);
 
        /*
         *      Check that the command queued to the controller
         */
-       if (status == -EINPROGRESS) {
-               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
+       if (status == -EINPROGRESS)
                return 0;
-       }
 
        printk(KERN_WARNING "aac_read: aac_fib_send failed with status: %d.\n", status);
        /*
@@ -1792,16 +1791,14 @@ static int aac_write(struct scsi_cmnd * scsicmd)
                printk(KERN_WARNING "aac_write: fib allocation failed\n");
                return -1;
        }
-
+       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
        status = aac_adapter_write(cmd_fibcontext, scsicmd, lba, count, fua);
 
        /*
         *      Check that the command queued to the controller
         */
-       if (status == -EINPROGRESS) {
-               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
+       if (status == -EINPROGRESS)
                return 0;
-       }
 
        printk(KERN_WARNING "aac_write: aac_fib_send failed with status: %d\n", status);
        /*
@@ -1951,6 +1948,7 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
        synchronizecmd->cid = cpu_to_le32(scmd_id(scsicmd));
        synchronizecmd->count =
             cpu_to_le32(sizeof(((struct aac_synchronize_reply *)NULL)->data));
+       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
 
        /*
         *      Now send the Fib to the adapter
@@ -1966,10 +1964,8 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
        /*
         *      Check that the command queued to the controller
         */
-       if (status == -EINPROGRESS) {
-               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
+       if (status == -EINPROGRESS)
                return 0;
-       }
 
        printk(KERN_WARNING
                "aac_synchronize: aac_fib_send failed with status: %d.\n", status);
@@ -2031,6 +2027,7 @@ static int aac_start_stop(struct scsi_cmnd *scsicmd)
        pmcmd->cid = cpu_to_le32(sdev_id(sdev));
        pmcmd->parm = (scsicmd->cmnd[1] & 1) ?
                cpu_to_le32(CT_PM_UNIT_IMMEDIATE) : 0;
+       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
 
        /*
         *      Now send the Fib to the adapter
@@ -2046,10 +2043,8 @@ static int aac_start_stop(struct scsi_cmnd *scsicmd)
        /*
         *      Check that the command queued to the controller
         */
-       if (status == -EINPROGRESS) {
-               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
+       if (status == -EINPROGRESS)
                return 0;
-       }
 
        aac_fib_complete(cmd_fibcontext);
        aac_fib_free(cmd_fibcontext);
@@ -2798,15 +2793,14 @@ static int aac_send_srb_fib(struct scsi_cmnd* scsicmd)
        if (!(cmd_fibcontext = aac_fib_alloc(dev))) {
                return -1;
        }
+       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
        status = aac_adapter_scsi(cmd_fibcontext, scsicmd);
 
        /*
         *      Check that the command queued to the controller
         */
-       if (status == -EINPROGRESS) {
-               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
+       if (status == -EINPROGRESS)
                return 0;
-       }
 
        printk(KERN_WARNING "aac_srb: aac_fib_send failed with status: %d\n", status);
        aac_fib_complete(cmd_fibcontext);