]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
isci: removing the kmalloc in smp request construct
authorDave Jiang <dave.jiang@intel.com>
Wed, 25 May 2011 02:21:57 +0000 (02:21 +0000)
committerDan Williams <dan.j.williams@intel.com>
Sun, 3 Jul 2011 11:04:50 +0000 (04:04 -0700)
It doesn't look like there is any reason to do a kmalloc. We can do the
byte swap in place and avoid the allocation. This allow us to remove
a kmalloc and a memcpy.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/scsi/isci/request.c

index 063ef04080d50de0aaf2dcc0ba76ab622ba6f891..7c0928ed9e630b92087d7e7e9a3b7a9836948f09 100644 (file)
@@ -3187,7 +3187,7 @@ static enum sci_status isci_request_stp_request_construct(
  */
 static void
 scu_smp_request_construct_task_context(struct scic_sds_request *sci_req,
-                                      struct smp_req *smp_req)
+                                      ssize_t req_len)
 {
        dma_addr_t dma_addr;
        struct scic_sds_controller *scic;
@@ -3197,7 +3197,7 @@ scu_smp_request_construct_task_context(struct scic_sds_request *sci_req,
        ssize_t word_cnt = sizeof(struct smp_req) / sizeof(u32);
 
        /* byte swap the smp request. */
-       sci_swab32_cpy(&sci_req->smp.cmd, smp_req,
+       sci_swab32_cpy(&sci_req->smp.cmd, &sci_req->smp.cmd,
                       word_cnt);
 
        task_context = scic_sds_request_get_task_context(sci_req);
@@ -3238,7 +3238,7 @@ scu_smp_request_construct_task_context(struct scic_sds_request *sci_req,
        task_context->address_modifier = 0;
 
        /* 10h */
-       task_context->ssp_command_iu_length = smp_req->req_len;
+       task_context->ssp_command_iu_length = req_len;
 
        /* 14h */
        task_context->transfer_length_bytes = 0;
@@ -3299,22 +3299,18 @@ scu_smp_request_construct_task_context(struct scic_sds_request *sci_req,
        task_context->response_iu_lower = 0;
 }
 
-static enum sci_status scic_io_request_construct_smp(struct scic_sds_request *sci_req)
+static enum sci_status
+scic_io_request_construct_smp(struct scic_sds_request *sci_req)
 {
-       struct smp_req *smp_req = kmalloc(sizeof(*smp_req), GFP_KERNEL);
-
-       if (!smp_req)
-               return SCI_FAILURE_INSUFFICIENT_RESOURCES;
+       struct smp_req *smp_req = &sci_req->smp.cmd;
 
        sci_req->protocol = SCIC_SMP_PROTOCOL;
 
-       /* Construct the SMP SCU Task Context */
-       memcpy(smp_req, &sci_req->smp.cmd, sizeof(*smp_req));
-
        /*
         * Look at the SMP requests' header fields; for certain SAS 1.x SMP
         * functions under SAS 2.0, a zero request length really indicates
-        * a non-zero default length. */
+        * a non-zero default length.
+        */
        if (smp_req->req_len == 0) {
                switch (smp_req->func) {
                case SMP_DISCOVER:
@@ -3332,12 +3328,10 @@ static enum sci_status scic_io_request_construct_smp(struct scic_sds_request *sc
                }
        }
 
-       scu_smp_request_construct_task_context(sci_req, smp_req);
+       scu_smp_request_construct_task_context(sci_req, smp_req->req_len);
 
        sci_base_state_machine_change_state(&sci_req->state_machine,
-               SCI_BASE_REQUEST_STATE_CONSTRUCTED);
-
-       kfree(smp_req);
+                                           SCI_BASE_REQUEST_STATE_CONSTRUCTED);
 
        return SCI_SUCCESS;
 }