All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] gpio: dwapb_gpio: Change to use devm_kcalloc()
  2018-09-06 14:48 [U-Boot] [PATCH] gpio: dwapb_gpio: Change to use devm_kcalloc() Ley Foon Tan
@ 2018-09-06 10:05 ` Marek Vasut
  2018-09-07  0:57   ` Ley Foon Tan
  0 siblings, 1 reply; 3+ messages in thread
From: Marek Vasut @ 2018-09-06 10:05 UTC (permalink / raw)
  To: u-boot

On 09/06/2018 04:48 PM, Ley Foon Tan wrote:
> Change to use managed resource function devm_kcalloc(),
> so it will auto free memory when driver is removed.
> 
> Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
> ---
>  drivers/gpio/dwapb_gpio.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
> index 0f6574d..1594434 100644
> --- a/drivers/gpio/dwapb_gpio.c
> +++ b/drivers/gpio/dwapb_gpio.c
> @@ -171,8 +171,7 @@ static int gpio_dwapb_bind(struct udevice *dev)
>  		if (!fdtdec_get_bool(blob, node, "gpio-controller"))
>  			continue;
>  
> -		plat = NULL;
> -		plat = calloc(1, sizeof(*plat));
> +		plat = devm_kcalloc(dev, 1, sizeof(*plat), GFP_KERNEL);
>  		if (!plat)
>  			return -ENOMEM;

You also need to drop the matching free()

-- 
Best regards,
Marek Vasut

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

* [U-Boot] [PATCH] gpio: dwapb_gpio: Change to use devm_kcalloc()
@ 2018-09-06 14:48 Ley Foon Tan
  2018-09-06 10:05 ` Marek Vasut
  0 siblings, 1 reply; 3+ messages in thread
From: Ley Foon Tan @ 2018-09-06 14:48 UTC (permalink / raw)
  To: u-boot

Change to use managed resource function devm_kcalloc(),
so it will auto free memory when driver is removed.

Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
---
 drivers/gpio/dwapb_gpio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index 0f6574d..1594434 100644
--- a/drivers/gpio/dwapb_gpio.c
+++ b/drivers/gpio/dwapb_gpio.c
@@ -171,8 +171,7 @@ static int gpio_dwapb_bind(struct udevice *dev)
 		if (!fdtdec_get_bool(blob, node, "gpio-controller"))
 			continue;
 
-		plat = NULL;
-		plat = calloc(1, sizeof(*plat));
+		plat = devm_kcalloc(dev, 1, sizeof(*plat), GFP_KERNEL);
 		if (!plat)
 			return -ENOMEM;
 
-- 
2.2.2

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

* [U-Boot] [PATCH] gpio: dwapb_gpio: Change to use devm_kcalloc()
  2018-09-06 10:05 ` Marek Vasut
@ 2018-09-07  0:57   ` Ley Foon Tan
  0 siblings, 0 replies; 3+ messages in thread
From: Ley Foon Tan @ 2018-09-07  0:57 UTC (permalink / raw)
  To: u-boot

On Thu, Sep 6, 2018 at 7:14 PM Marek Vasut <marex@denx.de> wrote:
>
> On 09/06/2018 04:48 PM, Ley Foon Tan wrote:
> > Change to use managed resource function devm_kcalloc(),
> > so it will auto free memory when driver is removed.
> >
> > Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
> > ---
> >  drivers/gpio/dwapb_gpio.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
> > index 0f6574d..1594434 100644
> > --- a/drivers/gpio/dwapb_gpio.c
> > +++ b/drivers/gpio/dwapb_gpio.c
> > @@ -171,8 +171,7 @@ static int gpio_dwapb_bind(struct udevice *dev)
> >               if (!fdtdec_get_bool(blob, node, "gpio-controller"))
> >                       continue;
> >
> > -             plat = NULL;
> > -             plat = calloc(1, sizeof(*plat));
> > +             plat = devm_kcalloc(dev, 1, sizeof(*plat), GFP_KERNEL);
> >               if (!plat)
> >                       return -ENOMEM;
>
> You also need to drop the matching free()
Yes, you are right. Will fix that.

Thanks.

Regards
Ley Foon

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

end of thread, other threads:[~2018-09-07  0:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-06 14:48 [U-Boot] [PATCH] gpio: dwapb_gpio: Change to use devm_kcalloc() Ley Foon Tan
2018-09-06 10:05 ` Marek Vasut
2018-09-07  0:57   ` Ley Foon Tan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.