linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: mockup: use devm_kcalloc() where applicable
@ 2017-06-01 11:47 Bartosz Golaszewski
  2017-06-01 11:47 ` Bartosz Golaszewski
  2017-06-01 11:47 ` Bartosz Golaszewski
  0 siblings, 2 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2017-06-01 11:47 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Alexandre Courbot,
	Bamvor Jian Zhang
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

This is a follow up to [1]. The patch proposes to use devm_kcalloc()
when allocating arrays of elements.

Bartosz Golaszewski (1):
  gpio: mockup: use devm_kcalloc() where applicable

 drivers/gpio/gpio-mockup.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

-- 
2.9.3

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

* [PATCH] gpio: mockup: use devm_kcalloc() where applicable
  2017-06-01 11:47 [PATCH] gpio: mockup: use devm_kcalloc() where applicable Bartosz Golaszewski
@ 2017-06-01 11:47 ` Bartosz Golaszewski
  2017-06-09  8:06   ` Linus Walleij
  2017-06-01 11:47 ` Bartosz Golaszewski
  1 sibling, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2017-06-01 11:47 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Alexandre Courbot,
	Bamvor Jian Zhang
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

When allocating a zeroed array of objects use devm_kcalloc() instead
of manually calculating the required size and using devm_kzalloc().

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
 drivers/gpio/gpio-mockup.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index 536a229..a6565e1 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -128,7 +128,7 @@ static int gpio_mockup_name_lines(struct device *dev,
 	char **names;
 	int i;
 
-	names = devm_kzalloc(dev, sizeof(char *) * gc->ngpio, GFP_KERNEL);
+	names = devm_kcalloc(dev, gc->ngpio, sizeof(char *), GFP_KERNEL);
 	if (!names)
 		return -ENOMEM;
 
@@ -308,8 +308,8 @@ static int gpio_mockup_add(struct device *dev,
 	gc->get_direction = gpio_mockup_get_direction;
 	gc->to_irq = gpio_mockup_to_irq;
 
-	chip->lines = devm_kzalloc(dev, sizeof(*chip->lines) * gc->ngpio,
-				   GFP_KERNEL);
+	chip->lines = devm_kcalloc(dev, gc->ngpio,
+				   sizeof(*chip->lines), GFP_KERNEL);
 	if (!chip->lines)
 		return -ENOMEM;
 
@@ -346,7 +346,7 @@ static int gpio_mockup_probe(struct platform_device *pdev)
 	/* Each chip is described by two values. */
 	num_chips = gpio_mockup_params_nr / 2;
 
-	chips = devm_kzalloc(dev, sizeof(*chips) * num_chips, GFP_KERNEL);
+	chips = devm_kcalloc(dev, num_chips, sizeof(*chips), GFP_KERNEL);
 	if (!chips)
 		return -ENOMEM;
 
-- 
2.9.3

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

* Re: [PATCH] gpio: mockup: use devm_kcalloc() where applicable
  2017-06-01 11:47 [PATCH] gpio: mockup: use devm_kcalloc() where applicable Bartosz Golaszewski
  2017-06-01 11:47 ` Bartosz Golaszewski
@ 2017-06-01 11:47 ` Bartosz Golaszewski
  1 sibling, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2017-06-01 11:47 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Alexandre Courbot,
	Bamvor Jian Zhang
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

2017-06-01 13:47 GMT+02:00 Bartosz Golaszewski <brgl@bgdev.pl>:
> This is a follow up to [1]. The patch proposes to use devm_kcalloc()
> when allocating arrays of elements.
>
> Bartosz Golaszewski (1):
>   gpio: mockup: use devm_kcalloc() where applicable
>
>  drivers/gpio/gpio-mockup.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> --
> 2.9.3
>

[1] https://lkml.org/lkml/2017/5/30/180

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

* Re: [PATCH] gpio: mockup: use devm_kcalloc() where applicable
  2017-06-01 11:47 ` Bartosz Golaszewski
@ 2017-06-09  8:06   ` Linus Walleij
  2017-06-09 11:29     ` Bartosz Golaszewski
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2017-06-09  8:06 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Andy Shevchenko, Alexandre Courbot, Bamvor Jian Zhang,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org

On Thu, Jun 1, 2017 at 1:47 PM, Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> When allocating a zeroed array of objects use devm_kcalloc() instead
> of manually calculating the required size and using devm_kzalloc().
>
> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>

This does not apply on the GPIO "devel" branch in my tree,
probably because of other patches from you :)

Could you rebase and resend?

Yours,
Linus Walleij

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

* Re: [PATCH] gpio: mockup: use devm_kcalloc() where applicable
  2017-06-09  8:06   ` Linus Walleij
@ 2017-06-09 11:29     ` Bartosz Golaszewski
  0 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2017-06-09 11:29 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Andy Shevchenko, Alexandre Courbot, Bamvor Jian Zhang,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org

2017-06-09 10:06 GMT+02:00 Linus Walleij <linus.walleij@linaro.org>:
> On Thu, Jun 1, 2017 at 1:47 PM, Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
>> When allocating a zeroed array of objects use devm_kcalloc() instead
>> of manually calculating the required size and using devm_kzalloc().
>>
>> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
>
> This does not apply on the GPIO "devel" branch in my tree,
> probably because of other patches from you :)
>
> Could you rebase and resend?
>
> Yours,
> Linus Walleij

I thought you would apply the previous patches first, but sure, I'll resend.

Thanks,
Bartosz

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

end of thread, other threads:[~2017-06-09 11:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-01 11:47 [PATCH] gpio: mockup: use devm_kcalloc() where applicable Bartosz Golaszewski
2017-06-01 11:47 ` Bartosz Golaszewski
2017-06-09  8:06   ` Linus Walleij
2017-06-09 11:29     ` Bartosz Golaszewski
2017-06-01 11:47 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).