public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm: Replace kzalloc with kcalloc
@ 2017-10-13  7:37 Harsha Sharma
  2017-10-13  7:58 ` Jani Nikula
  0 siblings, 1 reply; 3+ messages in thread
From: Harsha Sharma @ 2017-10-13  7:37 UTC (permalink / raw)
  To: daniel.vetter, seanpaul, jani.nikula
  Cc: dri-devel, linux-kernel, outreachy-kernel, Harsha Sharma

Prefer kcalloc over kzalloc to allocate an array.
This patch fixes checkcpatch issue.

Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
---
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(-)

diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index eab36a460638..5a84c3bc915d 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -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);
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 1b8f013ffa65..de31e52ab9cb 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -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;
diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c
index 06aee1741e96..759ed93f4ba8 100644
--- a/drivers/gpu/drm/drm_plane_helper.c
+++ b/drivers/gpu/drm/drm_plane_helper.c
@@ -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;
-- 
2.11.0

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

* Re: [PATCH v2] drm: Replace kzalloc with kcalloc
  2017-10-13  7:37 [PATCH v2] drm: Replace kzalloc with kcalloc Harsha Sharma
@ 2017-10-13  7:58 ` Jani Nikula
  2017-10-13 20:06   ` Sean Paul
  0 siblings, 1 reply; 3+ messages in thread
From: Jani Nikula @ 2017-10-13  7:58 UTC (permalink / raw)
  To: Harsha Sharma, daniel.vetter, seanpaul
  Cc: dri-devel, linux-kernel, outreachy-kernel, Harsha Sharma

On Fri, 13 Oct 2017, Harsha Sharma <harshasharmaiitr@gmail.com> wrote:
> Prefer kcalloc over kzalloc to allocate an array.
> This patch fixes checkcpatch issue.
>
> Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>

Reviewed-by: Jani Nikula <jani.nikula@intel.com>


> ---
> 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(-)
>
> diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
> index eab36a460638..5a84c3bc915d 100644
> --- a/drivers/gpu/drm/drm_crtc_helper.c
> +++ b/drivers/gpu/drm/drm_crtc_helper.c
> @@ -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);
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 1b8f013ffa65..de31e52ab9cb 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -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;
> diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c
> index 06aee1741e96..759ed93f4ba8 100644
> --- a/drivers/gpu/drm/drm_plane_helper.c
> +++ b/drivers/gpu/drm/drm_plane_helper.c
> @@ -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;

-- 
Jani Nikula, Intel Open Source Technology Center

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

* Re: [PATCH v2] drm: Replace kzalloc with kcalloc
  2017-10-13  7:58 ` Jani Nikula
@ 2017-10-13 20:06   ` Sean Paul
  0 siblings, 0 replies; 3+ messages in thread
From: Sean Paul @ 2017-10-13 20:06 UTC (permalink / raw)
  To: Jani Nikula
  Cc: Harsha Sharma, daniel.vetter, seanpaul, dri-devel, linux-kernel,
	outreachy-kernel

On Fri, Oct 13, 2017 at 10:58:33AM +0300, Jani Nikula wrote:
> On Fri, 13 Oct 2017, Harsha Sharma <harshasharmaiitr@gmail.com> wrote:
> > Prefer kcalloc over kzalloc to allocate an array.
> > This patch fixes checkcpatch issue.
> >
> > Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
> 
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> 

Applied to -misc-next, thanks!

Sean

> 
> > ---
> > 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(-)
> >
> > diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
> > index eab36a460638..5a84c3bc915d 100644
> > --- a/drivers/gpu/drm/drm_crtc_helper.c
> > +++ b/drivers/gpu/drm/drm_crtc_helper.c
> > @@ -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);
> > diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> > index 1b8f013ffa65..de31e52ab9cb 100644
> > --- a/drivers/gpu/drm/drm_fb_helper.c
> > +++ b/drivers/gpu/drm/drm_fb_helper.c
> > @@ -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;
> > diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c
> > index 06aee1741e96..759ed93f4ba8 100644
> > --- a/drivers/gpu/drm/drm_plane_helper.c
> > +++ b/drivers/gpu/drm/drm_plane_helper.c
> > @@ -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;
> 
> -- 
> Jani Nikula, Intel Open Source Technology Center

-- 
Sean Paul, Software Engineer, Google / Chromium OS

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

end of thread, other threads:[~2017-10-13 20:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-13  7:37 [PATCH v2] drm: Replace kzalloc with kcalloc Harsha Sharma
2017-10-13  7:58 ` Jani Nikula
2017-10-13 20:06   ` Sean Paul

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