Skip to contentSkip to conversation

Staging: greybus: Prefer kcalloc over kzalloc

PATCH Superseded [email protected] 3 participants 4 messages May 6, 2017 – May 9, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: greybus: Prefer kcalloc over kzalloc

From: Karthik Tummala <[email protected]>

Fixed following checkpatch.pl warning:
* WARNING: Prefer kcalloc over kzalloc with multiply

Instead of specifying no.of bytes * size as arugment in kzalloc, prefer kcalloc.

---
 drivers/staging/greybus/light.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/greybus/light.c +2 -2
index 1681362..861a249 100644
@@ -1030,7 +1030,7 @@ static int gb_lights_light_config(struct gb_lights *glights, u8 id)
 	light->channels_count = conf.channel_count;
 	light->name = kstrndup(conf.name, NAMES_MAX, GFP_KERNEL);
 
-	light->channels = kzalloc(light->channels_count *
+	light->channels = kcalloc(light->channels_count,
 				  sizeof(struct gb_channel), GFP_KERNEL);
 	if (!light->channels)
 		return -ENOMEM;
@@ -1167,7 +1167,7 @@ static int gb_lights_create_all(struct gb_lights *glights)
 	if (ret < 0)
 		goto out;
 
-	glights->lights = kzalloc(glights->lights_count *
+	glights->lights = kcalloc(glights->lights_count,
 				  sizeof(struct gb_light), GFP_KERNEL);
 	if (!glights->lights) {
 		ret = -ENOMEM;
Signature · 1 line
1.9.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Karthik,
Thanks for the patch.

Quoted 9 lines · On Sat, May 06, 2017 at 07:44:10PM +0530, [email protected] wrote:

From: Karthik Tummala <[email protected]>

Fixed following checkpatch.pl warning:
* WARNING: Prefer kcalloc over kzalloc with multiply

Instead of specifying no.of bytes * size as arugment in kzalloc, prefer kcalloc.

Can you send a v2 with a subject similar to the other commits in the file. i.e, starting with staging: greybus: light: ...

And you have a typo in the change log s/arugment/argument/.

If this two are fixed, you can add my:

Cheers,
Rui

Quoted 29 lines

---
drivers/staging/greybus/light.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/greybus/light.c +2 -2
index 1681362..861a249 100644
@@ -1030,7 +1030,7 @@ static int gb_lights_light_config(struct gb_lights *glights, u8 id)
 	light->channels_count = conf.channel_count;
 	light->name = kstrndup(conf.name, NAMES_MAX, GFP_KERNEL);
 
-	light->channels = kzalloc(light->channels_count *
+	light->channels = kcalloc(light->channels_count,
 				  sizeof(struct gb_channel), GFP_KERNEL);
 	if (!light->channels)
 		return -ENOMEM;
@@ -1167,7 +1167,7 @@ static int gb_lights_create_all(struct gb_lights *glights)
 	if (ret < 0)
 		goto out;
 
-	glights->lights = kzalloc(glights->lights_count *
+	glights->lights = kcalloc(glights->lights_count,
 				  sizeof(struct gb_light), GFP_KERNEL);
 	if (!glights->lights) {
 		ret = -ENOMEM;
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 1/1 Staging: greybus: light: Prefer kcalloc over kzalloc

From: Karthik Tummala <[email protected]>

Fixed following checkpatch.pl warning:
* WARNING: Prefer kcalloc over kzalloc with multiply

Instead of specifying no.of bytes * size as argument in kzalloc, prefer kcalloc.

---
Changes for v2:
- Changed subject line & fixed typo as suggested by Rui Miguel Silva

---
 drivers/staging/greybus/light.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/greybus/light.c +2 -2
index 1681362..861a249 100644
@@ -1030,7 +1030,7 @@ static int gb_lights_light_config(struct gb_lights *glights, u8 id)
 	light->channels_count = conf.channel_count;
 	light->name = kstrndup(conf.name, NAMES_MAX, GFP_KERNEL);
 
-	light->channels = kzalloc(light->channels_count *
+	light->channels = kcalloc(light->channels_count,
 				  sizeof(struct gb_channel), GFP_KERNEL);
 	if (!light->channels)
 		return -ENOMEM;
@@ -1167,7 +1167,7 @@ static int gb_lights_create_all(struct gb_lights *glights)
 	if (ret < 0)
 		goto out;
 
-	glights->lights = kzalloc(glights->lights_count *
+	glights->lights = kcalloc(glights->lights_count,
 				  sizeof(struct gb_light), GFP_KERNEL);
 	if (!glights->lights) {
 		ret = -ENOMEM;
Signature · 1 line
1.9.1
Acked-by on v2 1/1
#3 lore raw

Re: [greybus-dev] [PATCH v2] Staging: greybus: light: Prefer kcalloc over kzalloc

Quoted 32 lines · On 08-05-17, 18:05, [email protected] wrote:

From: Karthik Tummala <[email protected]>

Fixed following checkpatch.pl warning:
* WARNING: Prefer kcalloc over kzalloc with multiply

Instead of specifying no.of bytes * size as argument in kzalloc, prefer kcalloc.

---
Changes for v2:
- Changed subject line & fixed typo as suggested by Rui Miguel Silva

---
 drivers/staging/greybus/light.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/greybus/light.c +1 -1
index 1681362..861a249 100644
@@ -1030,7 +1030,7 @@ static int gb_lights_light_config(struct gb_lights *glights, u8 id)
 	light->channels_count = conf.channel_count;
 	light->name = kstrndup(conf.name, NAMES_MAX, GFP_KERNEL);
 
-	light->channels = kzalloc(light->channels_count *
+	light->channels = kcalloc(light->channels_count,
 				  sizeof(struct gb_channel), GFP_KERNEL);
 	if (!light->channels)
 		return -ENOMEM;

drivers/staging/greybus/light.c static int gb_lights_create_all(struct gb_lights *glights) · line 1173

Quoted 8 lines
drivers/staging/greybus/light.c +1 -1
@@ -1167,7 +1167,7 @@ static int gb_lights_create_all(struct gb_lights *glights)
 	if (ret < 0)
 		goto out;
 
-	glights->lights = kzalloc(glights->lights_count *
+	glights->lights = kcalloc(glights->lights_count,
 				  sizeof(struct gb_light), GFP_KERNEL);
 	if (!glights->lights) {
 		ret = -ENOMEM;
Signature · 1 line
viresh