mpt2sas: Copyright in driver sources is updated for year the 2014
[firefly-linux-kernel-4.4.55.git] / drivers / scsi / scsi.c
index df3306019a7eeaf2009411ba0328dc7450fc6034..1423cb17fbfda37e4c944b2e7e60feae14359b04 100644 (file)
@@ -377,6 +377,10 @@ scsi_alloc_host_cmd_pool(struct Scsi_Host *shost)
                pool->slab_flags |= SLAB_CACHE_DMA;
                pool->gfp_mask = __GFP_DMA;
        }
+
+       if (hostt->cmd_size)
+               hostt->cmd_pool = pool;
+
        return pool;
 }
 
@@ -421,8 +425,10 @@ out:
 out_free_slab:
        kmem_cache_destroy(pool->cmd_slab);
 out_free_pool:
-       if (hostt->cmd_size)
+       if (hostt->cmd_size) {
                scsi_free_host_cmd_pool(pool);
+               hostt->cmd_pool = NULL;
+       }
        goto out;
 }
 
@@ -444,8 +450,10 @@ static void scsi_put_host_cmd_pool(struct Scsi_Host *shost)
        if (!--pool->users) {
                kmem_cache_destroy(pool->cmd_slab);
                kmem_cache_destroy(pool->sense_slab);
-               if (hostt->cmd_size)
+               if (hostt->cmd_size) {
                        scsi_free_host_cmd_pool(pool);
+                       hostt->cmd_pool = NULL;
+               }
        }
        mutex_unlock(&host_cmd_pool_mutex);
 }
@@ -662,14 +670,10 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
                return SCSI_MLQUEUE_DEVICE_BUSY;
        }
 
-       /*
-        * If SCSI-2 or lower, store the LUN value in cmnd.
-        */
-       if (cmd->device->scsi_level <= SCSI_2 &&
-           cmd->device->scsi_level != SCSI_UNKNOWN) {
+       /* Store the LUN value in cmnd, if needed. */
+       if (cmd->device->lun_in_cdb)
                cmd->cmnd[1] = (cmd->cmnd[1] & 0x1f) |
                               (cmd->device->lun << 5 & 0xe0);
-       }
 
        scsi_log_send(cmd);