drm/amdkfd: Remove usage of alloc(sizeof(struct...
authorKent Russell <kent.russell@amd.com>
Wed, 16 Aug 2017 03:00:08 +0000 (23:00 -0400)
committerOded Gabbay <oded.gabbay@gmail.com>
Wed, 16 Aug 2017 03:00:08 +0000 (23:00 -0400)
See https://kernel.org/doc/html/latest/process/coding-style.html
under "14) Allocating Memory" for rationale behind removing the
x=alloc(sizeof(struct) style and using x=alloc(sizeof(*x) instead

Signed-off-by: Kent Russell <kent.russell@amd.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
drivers/gpu/drm/amd/amdkfd/kfd_queue.c

index 2e0337977fa64776fe931537afff6fd88a09ffb1..22a47b93b45b031babc757d38118e88882cf123c 100644 (file)
@@ -422,7 +422,7 @@ static int register_process_nocpsch(struct device_queue_manager *dqm,
 
        BUG_ON(!dqm || !qpd);
 
-       n = kzalloc(sizeof(struct device_process_node), GFP_KERNEL);
+       n = kzalloc(sizeof(*n), GFP_KERNEL);
        if (!n)
                return -ENOMEM;
 
@@ -1135,7 +1135,7 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
 
        pr_debug("Loading device queue manager\n");
 
-       dqm = kzalloc(sizeof(struct device_queue_manager), GFP_KERNEL);
+       dqm = kzalloc(sizeof(*dqm), GFP_KERNEL);
        if (!dqm)
                return NULL;
 
index 88447988686752b001dad644b5e3fb1d358a13e1..47e2e8a99809be4b81e792074de8b8f3825597e3 100644 (file)
@@ -283,7 +283,7 @@ struct kernel_queue *kernel_queue_init(struct kfd_dev *dev,
 
        BUG_ON(!dev);
 
-       kq = kzalloc(sizeof(struct kernel_queue), GFP_KERNEL);
+       kq = kzalloc(sizeof(*kq), GFP_KERNEL);
        if (!kq)
                return NULL;
 
index 9908227437d2b5a81c1b348fc8b1a48b85595a3e..dca4fc784fef17708c6ae088857c8cdbcd237b00 100644 (file)
@@ -406,7 +406,7 @@ struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type,
        BUG_ON(!dev);
        BUG_ON(type >= KFD_MQD_TYPE_MAX);
 
-       mqd = kzalloc(sizeof(struct mqd_manager), GFP_KERNEL);
+       mqd = kzalloc(sizeof(*mqd), GFP_KERNEL);
        if (!mqd)
                return NULL;
 
index 5ba3b40f787acd6c823bb345fa923cbd0a86f545..aaaa87a40cf21ac8ebe81c6242021248257aa0fe 100644 (file)
@@ -239,7 +239,7 @@ struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type,
        BUG_ON(!dev);
        BUG_ON(type >= KFD_MQD_TYPE_MAX);
 
-       mqd = kzalloc(sizeof(struct mqd_manager), GFP_KERNEL);
+       mqd = kzalloc(sizeof(*mqd), GFP_KERNEL);
        if (!mqd)
                return NULL;
 
index 8432f5f2c51147f3ca0b43d19f6088bdd96f49d8..1d056a69fae6a787786d6c5496feab594e87d050 100644 (file)
@@ -187,7 +187,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
                dev->dqm->ops.register_process(dev->dqm, &pdd->qpd);
        }
 
-       pqn = kzalloc(sizeof(struct process_queue_node), GFP_KERNEL);
+       pqn = kzalloc(sizeof(*pqn), GFP_KERNEL);
        if (!pqn) {
                retval = -ENOMEM;
                goto err_allocate_pqn;
index 0ab197077f2dc03e18a6e96ea5ddc179c8d0d498..5ad9f6f192aea263e49a10533363bc303024c76b 100644 (file)
@@ -65,17 +65,17 @@ void print_queue(struct queue *q)
 
 int init_queue(struct queue **q, const struct queue_properties *properties)
 {
-       struct queue *tmp;
+       struct queue *tmp_q;
 
        BUG_ON(!q);
 
-       tmp = kzalloc(sizeof(struct queue), GFP_KERNEL);
-       if (!tmp)
+       tmp_q = kzalloc(sizeof(*tmp_q), GFP_KERNEL);
+       if (!tmp_q)
                return -ENOMEM;
 
-       memcpy(&tmp->properties, properties, sizeof(struct queue_properties));
+       memcpy(&tmp_q->properties, properties, sizeof(*properties));
 
-       *q = tmp;
+       *q = tmp_q;
        return 0;
 }