summaryrefslogtreecommitdiff
path: root/drivers/sh/pfc/gpio.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2012-12-16 02:50:48 +0400
committerSimon Horman <horms+renesas@verge.net.au>2013-01-25 04:24:21 +0400
commit1724acfd598bdf688218bdd26a5f02dd55b6ec62 (patch)
treede92bd2a54456da3df5bc9a4f082f025447fe4fa /drivers/sh/pfc/gpio.c
parentc6193eacda6d50c405b0d484f5f2577ff9068a13 (diff)
downloadlinux-1724acfd598bdf688218bdd26a5f02dd55b6ec62.tar.xz
sh-pfc: Use devm_kzalloc()
Replace probe-time kmalloc()/kzalloc() calls with devm_kzalloc() and get rid of the corresponding kfree() calls. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Diffstat (limited to 'drivers/sh/pfc/gpio.c')
-rw-r--r--drivers/sh/pfc/gpio.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/sh/pfc/gpio.c b/drivers/sh/pfc/gpio.c
index a32ea8083b91..37493e5fe2ee 100644
--- a/drivers/sh/pfc/gpio.c
+++ b/drivers/sh/pfc/gpio.c
@@ -11,6 +11,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME " gpio: " fmt
+#include <linux/device.h>
#include <linux/init.h>
#include <linux/gpio.h>
#include <linux/slab.h>
@@ -143,7 +144,7 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc)
struct sh_pfc_chip *chip;
int ret;
- chip = kzalloc(sizeof(struct sh_pfc_chip), GFP_KERNEL);
+ chip = devm_kzalloc(pfc->dev, sizeof(*chip), GFP_KERNEL);
if (unlikely(!chip))
return -ENOMEM;
@@ -152,10 +153,8 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc)
sh_pfc_gpio_setup(chip);
ret = gpiochip_add(&chip->gpio_chip);
- if (unlikely(ret < 0)) {
- kfree(chip);
+ if (unlikely(ret < 0))
return ret;
- }
pfc->gpio = chip;
@@ -175,7 +174,6 @@ int sh_pfc_unregister_gpiochip(struct sh_pfc *pfc)
if (unlikely(ret < 0))
return ret;
- kfree(chip);
pfc->gpio = NULL;
return 0;
}