public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Replace kzalloc with kcalloc
@ 2019-01-15  5:22 Gustavo A. R. Silva
  2019-01-16 22:04 ` Alex Deucher
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2019-01-15  5:22 UTC (permalink / raw)
  To: Harry Wentland, Leo Li, Alex Deucher, Christian König,
	David (ChunMing) Zhou, David Airlie, Daniel Vetter
  Cc: amd-gfx, dri-devel, linux-kernel, Gustavo A. R. Silva

Replace kzalloc() function with its 2-factor argument form, kcalloc().

This patch replaces cases of:

	kzalloc(a * b, gfp)

with:
	kcalloc(a, b, gfp)

Also, improve the coding style and the use of sizeof during
allocation by changing sizeof(struct dc_surface_update) and
sizeof(struct dc_plane_state) to sizeof(*updates) and
sizeof(*surfaces), correspondingly.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index a3e65e457348..4c201de38329 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -5782,11 +5782,14 @@ dm_determine_update_type_for_commit(struct dc *dc,
 	struct dm_crtc_state *new_dm_crtc_state, *old_dm_crtc_state;
 	struct dc_stream_status *status = NULL;
 
-	struct dc_surface_update *updates = kzalloc(MAX_SURFACES * sizeof(struct dc_surface_update), GFP_KERNEL);
-	struct dc_plane_state *surface = kzalloc(MAX_SURFACES * sizeof(struct dc_plane_state), GFP_KERNEL);
+	struct dc_surface_update *updates;
+	struct dc_plane_state *surface;
 	struct dc_stream_update stream_update;
 	enum surface_update_type update_type = UPDATE_TYPE_FAST;
 
+	updates = kcalloc(MAX_SURFACES, sizeof(*updates), GFP_KERNEL);
+	surface = kcalloc(MAX_SURFACES, sizeof(*surface), GFP_KERNEL);
+
 	if (!updates || !surface) {
 		DRM_ERROR("Plane or surface update failed to allocate");
 		/* Set type to FULL to avoid crashing in DC*/
-- 
2.20.1


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

* Re: [PATCH] drm/amdgpu: Replace kzalloc with kcalloc
  2019-01-15  5:22 [PATCH] drm/amdgpu: Replace kzalloc with kcalloc Gustavo A. R. Silva
@ 2019-01-16 22:04 ` Alex Deucher
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2019-01-16 22:04 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Harry Wentland, Leo Li, Alex Deucher, Christian König,
	David (ChunMing) Zhou, David Airlie, Daniel Vetter,
	Maling list - DRI developers, amd-gfx list, LKML

On Tue, Jan 15, 2019 at 2:58 AM Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
>
> Replace kzalloc() function with its 2-factor argument form, kcalloc().
>
> This patch replaces cases of:
>
>         kzalloc(a * b, gfp)
>
> with:
>         kcalloc(a, b, gfp)
>
> Also, improve the coding style and the use of sizeof during
> allocation by changing sizeof(struct dc_surface_update) and
> sizeof(struct dc_plane_state) to sizeof(*updates) and
> sizeof(*surfaces), correspondingly.
>
> This code was detected with the help of Coccinelle.
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Applied.  thanks!

Alex

> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index a3e65e457348..4c201de38329 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -5782,11 +5782,14 @@ dm_determine_update_type_for_commit(struct dc *dc,
>         struct dm_crtc_state *new_dm_crtc_state, *old_dm_crtc_state;
>         struct dc_stream_status *status = NULL;
>
> -       struct dc_surface_update *updates = kzalloc(MAX_SURFACES * sizeof(struct dc_surface_update), GFP_KERNEL);
> -       struct dc_plane_state *surface = kzalloc(MAX_SURFACES * sizeof(struct dc_plane_state), GFP_KERNEL);
> +       struct dc_surface_update *updates;
> +       struct dc_plane_state *surface;
>         struct dc_stream_update stream_update;
>         enum surface_update_type update_type = UPDATE_TYPE_FAST;
>
> +       updates = kcalloc(MAX_SURFACES, sizeof(*updates), GFP_KERNEL);
> +       surface = kcalloc(MAX_SURFACES, sizeof(*surface), GFP_KERNEL);
> +
>         if (!updates || !surface) {
>                 DRM_ERROR("Plane or surface update failed to allocate");
>                 /* Set type to FULL to avoid crashing in DC*/
> --
> 2.20.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2019-01-16 22:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-15  5:22 [PATCH] drm/amdgpu: Replace kzalloc with kcalloc Gustavo A. R. Silva
2019-01-16 22:04 ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox