gpio: dwapb_gpio: Change to use devm_kcalloc()
PATCH 1/1 gpio: dwapb_gpio: Change to use devm_kcalloc()
Change to use managed resource function devm_kcalloc(), so it will auto free memory when driver is removed.
--- drivers/gpio/dwapb_gpio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpio/dwapb_gpio.c +1 -2
@@ -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 ;
Signature · 1 line
2.2.2
PATCH 1/1 gpio: dwapb_gpio: Change to use devm_kcalloc()
Quoted 13 lines · Ley Foon Tan
Change to use managed resource function
devm_kcalloc(), so it will auto free memory when driver is removed.Signed-off-by Ley Foon Tan <[email protected]>--- drivers/gpio/dwapb_gpio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpio/dwapb_gpio.c +0
-0
drivers/gpio/dwapb_gpio.c static int gpio_dwapb_bind(struct udevice *dev) · line 176
Quoted 8 lines
drivers/gpio/dwapb_gpio.c +1
-2@@ -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()
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 gpio: dwapb_gpio: Change to use devm_kcalloc()
Quoted 18 lines · Marek Vasut
Quoted 16 lines · Ley Foon Tan
Change to use managed resource function
devm_kcalloc(), so it will auto free memory when driver is removed.Signed-off-by Ley Foon Tan <[email protected]>--- drivers/gpio/dwapb_gpio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpio/dwapb_gpio.c +0
-0@@ -171,8 +171,7 @@ static int gpio_dwapb_bind(struct udevice *dev)if (!fdtdec_get_bool (blob, node,"gpio-controller" ))continue ;
Quoted 7 lines
drivers/gpio/dwapb_gpio.c static int gpio_dwapb_bind(struct udevice *dev) · line 176
Quoted 5 lines
drivers/gpio/dwapb_gpio.c +1
-2- 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