gpio: dwapb_gpio: Change to use devm_kcalloc()
PATCH v2 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.
---
v2:
- Remove free() function.
--- drivers/gpio/dwapb_gpio.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpio/dwapb_gpio.c +1 -3
@@ -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 ;
@@ -196,7 +195,6 @@ static int gpio_dwapb_bind(struct udevice *dev)return 0 ; err: -free (plat);return ret; }
Signature · 1 line
2.2.2
PATCH v2 1/1 gpio: dwapb_gpio: Change to use devm_kcalloc()
Quoted 27 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]>---
v2:
- Removefree()function.--- drivers/gpio/dwapb_gpio.c | 4 +--- 1 file changed, 1 insertion(+), 3 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 ;
drivers/gpio/dwapb_gpio.c static int gpio_dwapb_bind(struct udevice *dev) · line 198
Quoted 5 lines
drivers/gpio/dwapb_gpio.c +0
-1@@ -196,7 +195,6 @@ static int gpio_dwapb_bind(struct udevice *dev)return 0 ; err: -free (plat);return ret;
Well, this becomes return ret, right ? ;-)
Quoted 3 lines
drivers/gpio/dwapb_gpio.c +0
-0}
Signature · 2 lines
Best regards, Marek Vasut
PATCH v2 1/1 gpio: dwapb_gpio: Change to use devm_kcalloc()
Quoted 27 lines · Marek Vasut
Quoted 26 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]>---
v2:
- Removefree()function.--- drivers/gpio/dwapb_gpio.c | 4 +--- 1 file changed, 1 insertion(+), 3 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 ;
Quoted 8 lines
drivers/gpio/dwapb_gpio.c static int gpio_dwapb_bind(struct udevice *dev) · line 198
Quoted 6 lines
drivers/gpio/dwapb_gpio.c +0
-1@@ -196,7 +195,6 @@ static int gpio_dwapb_bind(struct udevice *dev)return 0 ; err: -free (plat);return ret;Well, this becomes return ret, right ? ;-)
Well, this vanishes completely ;-) But there're more strange snipets, better to show patch:
drivers/gpio/dwapb_gpio.c +2 -9
@@ -123,8 +123,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 ;
@@ -133,23 +132,17 @@ static int gpio_dwapb_bind(struct udevice *dev) plat->pins =fdtdec_get_int (blob, node,"snps,nr-gpios" ,0 ); plat->name =fdt_stringlist_get (blob, node,"bank-name" ,0 ,NULL ); -if (ret) - goto err; ret =device_bind (dev, dev->driver, plat->name, plat,-1 , &subdev);if (ret) - goto err; +return ret;dev_set_of_offset (subdev, node); bank++; }return 0 ; - -err: -free (plat); -return ret; }static const struct udevice_id gpio_dwapb_ids[] = {
Quoted 12 lines
Quoted 3 lines
drivers/gpio/dwapb_gpio.c +0
-0}Signature · 6 lines
Best regards, Marek Vasut _______________________________________________ U-Boot mailing list U-Boot at lists.denx.de https://lists.denx.de/listinfo/u-boot