[PATCH 09/19] drm/amdkfd: Remove usage of alloc(sizeof(struct...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Aug 12, 2017 at 12:56 AM, Felix Kuehling <Felix.Kuehling at amd.com> wrote:
> From: Kent Russell <kent.russell at amd.com>
>
> 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 at amd.com>
> Signed-off-by: Felix Kuehling <Felix.Kuehling at amd.com>
> ---
>  drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  |  4 ++--
>  drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c          |  2 +-
>  drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c       |  2 +-
>  drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c        |  2 +-
>  drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c |  2 +-
>  drivers/gpu/drm/amd/amdkfd/kfd_queue.c                 | 10 +++++-----
>  6 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> index 2003a7e..68fe6ed 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> @@ -420,7 +420,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;
>
> @@ -1133,7 +1133,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;
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
> index 8844798..47e2e8a 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
> @@ -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;
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c
> index 9908227..dca4fc7 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c
> @@ -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;
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c
> index 5ba3b40..aaaa87a 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c
> @@ -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;
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> index 8432f5f..1d056a6 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> @@ -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;
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_queue.c b/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
> index 0ab1970..5ad9f6f 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
> @@ -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;
>  }
>
> --
> 2.7.4
>

This patch is:
Reviewed-by: Oded Gabbay <oded.gabbay at gmail.com>


[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux