drm: Replace kzalloc with kcalloc
Subsystems (2)
PATCH v2 1/1 drm: Replace kzalloc with kcalloc
Prefer kcalloc over kzalloc to allocate an array.
This patch fixes checkcpatch issue.
Signed-off-by Harsha Sharma <[email protected]>
---
Changes in v2:
-kcalloc will take 3 arguments
drivers/gpu/drm/drm_crtc_helper.c | 4 ++-- drivers/gpu/drm/drm_fb_helper.c | 2 +- drivers/gpu/drm/drm_plane_helper.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_crtc_helper.c +2 -2
@@ -562,12 +562,12 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set,* Allocate space for the backup of all (non-pointer) encoder and * connector data. */ - save_encoder_crtcs =kzalloc (dev->mode_config.num_encoder * + save_encoder_crtcs =kcalloc (dev->mode_config.num_encoder,sizeof (struct drm_crtc *),GFP_KERNEL );if (!save_encoder_crtcs)return -ENOMEM ; - save_connector_encoders =kzalloc (dev->mode_config.num_connector * + save_connector_encoders =kcalloc (dev->mode_config.num_connector,sizeof (struct drm_encoder *),GFP_KERNEL );if (!save_connector_encoders) {kfree (save_encoder_crtcs);
drivers/gpu/drm/drm_fb_helper.c +1 -1
@@ -2266,7 +2266,7 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,if (modes[n] ==NULL )return best_score; - crtcs =kzalloc (fb_helper->connector_count * + crtcs =kcalloc (fb_helper->connector_count,sizeof (struct drm_fb_helper_crtc *),GFP_KERNEL );if (!crtcs)return best_score;
drivers/gpu/drm/drm_plane_helper.c +1 -1
@@ -354,7 +354,7 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,/* Find current connectors for CRTC */ num_connectors =get_connectors_for_crtc (crtc,NULL ,0 );BUG_ON (num_connectors ==0 ); - connector_list =kzalloc (num_connectors *sizeof (*connector_list), + connector_list =kcalloc (num_connectors,sizeof (*connector_list),GFP_KERNEL );if (!connector_list)return -ENOMEM ;
Signature · 1 line
2.11.0
Quoted 4 lines · Harsha Sharma
Prefer kcalloc over kzalloc to allocate an array.
This patch fixes checkcpatch issue.Signed-off-by Harsha Sharma <[email protected]>
Reviewed-by Jani Nikula <[email protected]>
Quoted 54 lines
---
Changes in v2:
-kcalloc will take 3 argumentsdrivers/gpu/drm/drm_crtc_helper.c | 4 ++-- drivers/gpu/drm/drm_fb_helper.c | 2 +- drivers/gpu/drm/drm_plane_helper.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/drm_crtc_helper.c +2
-2@@ -562,12 +562,12 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set,* Allocate space for the backup of all (non-pointer) encoder and * connector data. */ - save_encoder_crtcs =kzalloc (dev->mode_config.num_encoder * + save_encoder_crtcs =kcalloc (dev->mode_config.num_encoder,sizeof (struct drm_crtc *),GFP_KERNEL );if (!save_encoder_crtcs)return -ENOMEM ; - save_connector_encoders =kzalloc (dev->mode_config.num_connector * + save_connector_encoders =kcalloc (dev->mode_config.num_connector,sizeof (struct drm_encoder *),GFP_KERNEL );if (!save_connector_encoders) {kfree (save_encoder_crtcs);drivers/gpu/drm/drm_fb_helper.c +1
-1@@ -2266,7 +2266,7 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,if (modes[n] ==NULL )return best_score; - crtcs =kzalloc (fb_helper->connector_count * + crtcs =kcalloc (fb_helper->connector_count,sizeof (struct drm_fb_helper_crtc *),GFP_KERNEL );if (!crtcs)return best_score;drivers/gpu/drm/drm_plane_helper.c +1
-1@@ -354,7 +354,7 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,/* Find current connectors for CRTC */ num_connectors =get_connectors_for_crtc (crtc,NULL ,0 );BUG_ON (num_connectors ==0 ); - connector_list =kzalloc (num_connectors *sizeof (*connector_list), + connector_list =kcalloc (num_connectors,sizeof (*connector_list),GFP_KERNEL );if (!connector_list)return -ENOMEM ;
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sean Paul
AppliedQuoted 8 lines · Jani Nikula
Quoted 4 lines · Harsha Sharma
Prefer kcalloc over kzalloc to allocate an array.
This patch fixes checkcpatch issue.Signed-off-by Harsha Sharma <[email protected]>Reviewed-by Jani Nikula <[email protected]>
Applied to -misc-next, thanks!
Sean
Quoted 58 lines
Quoted 55 lines
---
Changes in v2:
-kcalloc will take 3 argumentsdrivers/gpu/drm/drm_crtc_helper.c | 4 ++-- drivers/gpu/drm/drm_fb_helper.c | 2 +- drivers/gpu/drm/drm_plane_helper.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/drm_crtc_helper.c +2
-2@@ -562,12 +562,12 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set,* Allocate space for the backup of all (non-pointer) encoder and * connector data. */ - save_encoder_crtcs =kzalloc (dev->mode_config.num_encoder * + save_encoder_crtcs =kcalloc (dev->mode_config.num_encoder,sizeof (struct drm_crtc *),GFP_KERNEL );if (!save_encoder_crtcs)return -ENOMEM ; - save_connector_encoders =kzalloc (dev->mode_config.num_connector * + save_connector_encoders =kcalloc (dev->mode_config.num_connector,sizeof (struct drm_encoder *),GFP_KERNEL );if (!save_connector_encoders) {kfree (save_encoder_crtcs);drivers/gpu/drm/drm_fb_helper.c +1
-1@@ -2266,7 +2266,7 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,if (modes[n] ==NULL )return best_score; - crtcs =kzalloc (fb_helper->connector_count * + crtcs =kcalloc (fb_helper->connector_count,sizeof (struct drm_fb_helper_crtc *),GFP_KERNEL );if (!crtcs)return best_score;drivers/gpu/drm/drm_plane_helper.c +1
-1@@ -354,7 +354,7 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,/* Find current connectors for CRTC */ num_connectors =get_connectors_for_crtc (crtc,NULL ,0 );BUG_ON (num_connectors ==0 ); - connector_list =kzalloc (num_connectors *sizeof (*connector_list), + connector_list =kcalloc (num_connectors,sizeof (*connector_list),GFP_KERNEL );if (!connector_list)return -ENOMEM ;Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel