summaryrefslogtreecommitdiff
path: root/drivers/gpio
diff options
context:
space:
mode:
authorLey Foon Tan <ley.foon.tan@intel.com>2018-09-19 16:26:33 +0800
committerMarek Vasut <marex@denx.de>2018-10-03 12:56:50 +0200
commit86d56a5da5b2d50879c1ea955c8e1eed5d27fa7d (patch)
treeb6f0e5e53aacb0b92fd90e9a374f5ea49c618651 /drivers/gpio
parent592cd5defd4f71d34ffcbd8dd3326bc10f662e20 (diff)
downloadu-boot-86d56a5da5b2d50879c1ea955c8e1eed5d27fa7d.tar.gz
u-boot-86d56a5da5b2d50879c1ea955c8e1eed5d27fa7d.tar.bz2
u-boot-86d56a5da5b2d50879c1ea955c8e1eed5d27fa7d.zip
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. Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/dwapb_gpio.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index 0f6574d5da..68836a7902 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;
@@ -181,23 +180,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 int gpio_dwapb_remove(struct udevice *dev)