All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm/amd/amdgpu: cleanup the code style a bit
@ 2021-11-15 12:09 Bernard Zhao
  2021-11-17 21:27   ` Alex Deucher
  0 siblings, 1 reply; 4+ messages in thread
From: Bernard Zhao @ 2021-11-15 12:09 UTC (permalink / raw)
  To: Alex Deucher, Christian König, Pan, Xinhui, David Airlie,
	Daniel Vetter, Candice Li, Monk liu, John Clements, Jingwen Chen,
	Bernard Zhao, Peng Ju Zhou, Jiawei Gu, Bokun Zhang, Zhigang Luo,
	Lee Jones, amd-gfx, dri-devel, linux-kernel

This change is to cleanup the code style a bit.

Signed-off-by: Bernard Zhao <bernard@vivo.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index 04cf9b207e62..3fc49823f527 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -283,17 +283,15 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev)
 
 	*data = kmalloc(sizeof(struct amdgpu_virt_ras_err_handler_data), GFP_KERNEL);
 	if (!*data)
-		return -ENOMEM;
+		goto data_failure;
 
 	bps = kmalloc_array(align_space, sizeof((*data)->bps), GFP_KERNEL);
-	bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), GFP_KERNEL);
+	if (!bps)
+		goto bps_failure;
 
-	if (!bps || !bps_bo) {
-		kfree(bps);
-		kfree(bps_bo);
-		kfree(*data);
-		return -ENOMEM;
-	}
+	bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), GFP_KERNEL);
+	if (!bps_bo)
+		goto bps_bo_failure;
 
 	(*data)->bps = bps;
 	(*data)->bps_bo = bps_bo;
@@ -303,6 +301,13 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev)
 	virt->ras_init_done = true;
 
 	return 0;
+
+bps_bo_failure:
+	kfree(bps);
+bps_failure:
+	kfree(*data);
+data_failure:
+	return -ENOMEM;
 }
 
 static void amdgpu_virt_ras_release_bp(struct amdgpu_device *adev)
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] drm/amd/amdgpu: cleanup the code style a bit
  2021-11-15 12:09 [PATCH v2] drm/amd/amdgpu: cleanup the code style a bit Bernard Zhao
  2021-11-17 21:27   ` Alex Deucher
@ 2021-11-17 21:27   ` Alex Deucher
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2021-11-17 21:27 UTC (permalink / raw)
  To: Bernard Zhao
  Cc: Alex Deucher, Christian König, Pan, Xinhui, David Airlie,
	Daniel Vetter, Candice Li, Monk liu, John Clements, Jingwen Chen,
	Peng Ju Zhou, Jiawei Gu, Bokun Zhang, Zhigang Luo, Lee Jones,
	amd-gfx list, Maling list - DRI developers, LKML

Applied.  Thanks!

Alex

On Mon, Nov 15, 2021 at 7:09 AM Bernard Zhao <bernard@vivo.com> wrote:
>
> This change is to cleanup the code style a bit.
>
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 21 +++++++++++++--------
>  1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> index 04cf9b207e62..3fc49823f527 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> @@ -283,17 +283,15 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev)
>
>         *data = kmalloc(sizeof(struct amdgpu_virt_ras_err_handler_data), GFP_KERNEL);
>         if (!*data)
> -               return -ENOMEM;
> +               goto data_failure;
>
>         bps = kmalloc_array(align_space, sizeof((*data)->bps), GFP_KERNEL);
> -       bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), GFP_KERNEL);
> +       if (!bps)
> +               goto bps_failure;
>
> -       if (!bps || !bps_bo) {
> -               kfree(bps);
> -               kfree(bps_bo);
> -               kfree(*data);
> -               return -ENOMEM;
> -       }
> +       bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), GFP_KERNEL);
> +       if (!bps_bo)
> +               goto bps_bo_failure;
>
>         (*data)->bps = bps;
>         (*data)->bps_bo = bps_bo;
> @@ -303,6 +301,13 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev)
>         virt->ras_init_done = true;
>
>         return 0;
> +
> +bps_bo_failure:
> +       kfree(bps);
> +bps_failure:
> +       kfree(*data);
> +data_failure:
> +       return -ENOMEM;
>  }
>
>  static void amdgpu_virt_ras_release_bp(struct amdgpu_device *adev)
> --
> 2.33.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] drm/amd/amdgpu: cleanup the code style a bit
@ 2021-11-17 21:27   ` Alex Deucher
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2021-11-17 21:27 UTC (permalink / raw)
  To: Bernard Zhao
  Cc: Jiawei Gu, Zhigang Luo, David Airlie, Bokun Zhang, Jingwen Chen,
	Pan, Xinhui, LKML, amd-gfx list, Maling list - DRI developers,
	Alex Deucher, Peng Ju Zhou, Lee Jones, Candice Li, John Clements,
	Christian König, Monk liu

Applied.  Thanks!

Alex

On Mon, Nov 15, 2021 at 7:09 AM Bernard Zhao <bernard@vivo.com> wrote:
>
> This change is to cleanup the code style a bit.
>
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 21 +++++++++++++--------
>  1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> index 04cf9b207e62..3fc49823f527 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> @@ -283,17 +283,15 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev)
>
>         *data = kmalloc(sizeof(struct amdgpu_virt_ras_err_handler_data), GFP_KERNEL);
>         if (!*data)
> -               return -ENOMEM;
> +               goto data_failure;
>
>         bps = kmalloc_array(align_space, sizeof((*data)->bps), GFP_KERNEL);
> -       bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), GFP_KERNEL);
> +       if (!bps)
> +               goto bps_failure;
>
> -       if (!bps || !bps_bo) {
> -               kfree(bps);
> -               kfree(bps_bo);
> -               kfree(*data);
> -               return -ENOMEM;
> -       }
> +       bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), GFP_KERNEL);
> +       if (!bps_bo)
> +               goto bps_bo_failure;
>
>         (*data)->bps = bps;
>         (*data)->bps_bo = bps_bo;
> @@ -303,6 +301,13 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev)
>         virt->ras_init_done = true;
>
>         return 0;
> +
> +bps_bo_failure:
> +       kfree(bps);
> +bps_failure:
> +       kfree(*data);
> +data_failure:
> +       return -ENOMEM;
>  }
>
>  static void amdgpu_virt_ras_release_bp(struct amdgpu_device *adev)
> --
> 2.33.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] drm/amd/amdgpu: cleanup the code style a bit
@ 2021-11-17 21:27   ` Alex Deucher
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2021-11-17 21:27 UTC (permalink / raw)
  To: Bernard Zhao
  Cc: Jiawei Gu, Zhigang Luo, David Airlie, Bokun Zhang, Jingwen Chen,
	Pan, Xinhui, LKML, amd-gfx list, Maling list - DRI developers,
	Daniel Vetter, Alex Deucher, Lee Jones, Candice Li,
	John Clements, Christian König, Monk liu

Applied.  Thanks!

Alex

On Mon, Nov 15, 2021 at 7:09 AM Bernard Zhao <bernard@vivo.com> wrote:
>
> This change is to cleanup the code style a bit.
>
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 21 +++++++++++++--------
>  1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> index 04cf9b207e62..3fc49823f527 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> @@ -283,17 +283,15 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev)
>
>         *data = kmalloc(sizeof(struct amdgpu_virt_ras_err_handler_data), GFP_KERNEL);
>         if (!*data)
> -               return -ENOMEM;
> +               goto data_failure;
>
>         bps = kmalloc_array(align_space, sizeof((*data)->bps), GFP_KERNEL);
> -       bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), GFP_KERNEL);
> +       if (!bps)
> +               goto bps_failure;
>
> -       if (!bps || !bps_bo) {
> -               kfree(bps);
> -               kfree(bps_bo);
> -               kfree(*data);
> -               return -ENOMEM;
> -       }
> +       bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), GFP_KERNEL);
> +       if (!bps_bo)
> +               goto bps_bo_failure;
>
>         (*data)->bps = bps;
>         (*data)->bps_bo = bps_bo;
> @@ -303,6 +301,13 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev)
>         virt->ras_init_done = true;
>
>         return 0;
> +
> +bps_bo_failure:
> +       kfree(bps);
> +bps_failure:
> +       kfree(*data);
> +data_failure:
> +       return -ENOMEM;
>  }
>
>  static void amdgpu_virt_ras_release_bp(struct amdgpu_device *adev)
> --
> 2.33.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-17 21:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-15 12:09 [PATCH v2] drm/amd/amdgpu: cleanup the code style a bit Bernard Zhao
2021-11-17 21:27 ` Alex Deucher
2021-11-17 21:27   ` Alex Deucher
2021-11-17 21:27   ` Alex Deucher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.