From: Ley Foon Tan Date: Fri, 7 Sep 2018 14:24:38 +0800 Subject: [U-Boot] [PATCH v2] gpio: dwapb_gpio: Change to use devm_kcalloc() Message-ID: <1536301478-12069-1-git-send-email-ley.foon.tan@intel.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Change to use managed resource function devm_kcalloc(), so it will auto free memory when driver is removed. Signed-off-by: Ley Foon Tan --- v2: - Remove free() function. --- drivers/gpio/dwapb_gpio.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c index 0f6574d..6f9d17d 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; @@ -196,7 +195,6 @@ static int gpio_dwapb_bind(struct udevice *dev) return 0; err: - free(plat); return ret; } -- 2.2.2