summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-janz-ttl.c
diff options
context:
space:
mode:
authorabdoulaye berthe <berthe.ab@gmail.com>2014-05-13 18:42:12 +0200
committerLinus Walleij <linus.walleij@linaro.org>2014-05-16 17:52:37 +0200
commitae28193e01c8467f448e77234a074bae05b7a66f (patch)
tree914d38f42061a36176ffc577a631f9d589a3a0fe /drivers/gpio/gpio-janz-ttl.c
parent0ed3398ed8086597ff53d119fa48fa466f2f2754 (diff)
downloadop-kernel-dev-ae28193e01c8467f448e77234a074bae05b7a66f.zip
op-kernel-dev-ae28193e01c8467f448e77234a074bae05b7a66f.tar.gz
gpio: janzttl: use devm function
This uses dem function for mem allocation Signed-off-by: abdoulaye berthe <berthe.ab@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-janz-ttl.c')
-rw-r--r--drivers/gpio/gpio-janz-ttl.c37
1 files changed, 8 insertions, 29 deletions
diff --git a/drivers/gpio/gpio-janz-ttl.c b/drivers/gpio/gpio-janz-ttl.c
index 255806b..42852ea 100644
--- a/drivers/gpio/gpio-janz-ttl.c
+++ b/drivers/gpio/gpio-janz-ttl.c
@@ -152,33 +152,21 @@ static int ttl_probe(struct platform_device *pdev)
pdata = dev_get_platdata(&pdev->dev);
if (!pdata) {
dev_err(dev, "no platform data\n");
- ret = -ENXIO;
- goto out_return;
+ return -ENXIO;
}
- mod = kzalloc(sizeof(*mod), GFP_KERNEL);
- if (!mod) {
- ret = -ENOMEM;
- goto out_return;
- }
+ mod = devm_kzalloc(dev, sizeof(*mod), GFP_KERNEL);
+ if (!mod)
+ return -ENOMEM;
platform_set_drvdata(pdev, mod);
spin_lock_init(&mod->lock);
/* get access to the MODULbus registers for this module */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(dev, "MODULbus registers not found\n");
- ret = -ENODEV;
- goto out_free_mod;
- }
-
- mod->regs = ioremap(res->start, resource_size(res));
- if (!mod->regs) {
- dev_err(dev, "MODULbus registers not ioremap\n");
- ret = -ENOMEM;
- goto out_free_mod;
- }
+ mod->regs = devm_ioremap_resource(dev, res);
+ if (IS_ERR(mod->regs))
+ return PTR_ERR(mod->regs);
ttl_setup_device(mod);
@@ -197,17 +185,10 @@ static int ttl_probe(struct platform_device *pdev)
ret = gpiochip_add(gpio);
if (ret) {
dev_err(dev, "unable to add GPIO chip\n");
- goto out_iounmap_regs;
+ return ret;
}
return 0;
-
-out_iounmap_regs:
- iounmap(mod->regs);
-out_free_mod:
- kfree(mod);
-out_return:
- return ret;
}
static int ttl_remove(struct platform_device *pdev)
@@ -222,8 +203,6 @@ static int ttl_remove(struct platform_device *pdev)
return ret;
}
- iounmap(mod->regs);
- kfree(mod);
return 0;
}
OpenPOWER on IntegriCloud