Commit ae28193e authored by abdoulaye berthe's avatar abdoulaye berthe Committed by Linus Walleij

gpio: janzttl: use devm function

This uses dem function for mem allocation
Signed-off-by: default avatarabdoulaye berthe <berthe.ab@gmail.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 0ed3398e
...@@ -152,33 +152,21 @@ static int ttl_probe(struct platform_device *pdev) ...@@ -152,33 +152,21 @@ static int ttl_probe(struct platform_device *pdev)
pdata = dev_get_platdata(&pdev->dev); pdata = dev_get_platdata(&pdev->dev);
if (!pdata) { if (!pdata) {
dev_err(dev, "no platform data\n"); dev_err(dev, "no platform data\n");
ret = -ENXIO; return -ENXIO;
goto out_return;
} }
mod = kzalloc(sizeof(*mod), GFP_KERNEL); mod = devm_kzalloc(dev, sizeof(*mod), GFP_KERNEL);
if (!mod) { if (!mod)
ret = -ENOMEM; return -ENOMEM;
goto out_return;
}
platform_set_drvdata(pdev, mod); platform_set_drvdata(pdev, mod);
spin_lock_init(&mod->lock); spin_lock_init(&mod->lock);
/* get access to the MODULbus registers for this module */ /* get access to the MODULbus registers for this module */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { mod->regs = devm_ioremap_resource(dev, res);
dev_err(dev, "MODULbus registers not found\n"); if (IS_ERR(mod->regs))
ret = -ENODEV; return PTR_ERR(mod->regs);
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;
}
ttl_setup_device(mod); ttl_setup_device(mod);
...@@ -197,17 +185,10 @@ static int ttl_probe(struct platform_device *pdev) ...@@ -197,17 +185,10 @@ static int ttl_probe(struct platform_device *pdev)
ret = gpiochip_add(gpio); ret = gpiochip_add(gpio);
if (ret) { if (ret) {
dev_err(dev, "unable to add GPIO chip\n"); dev_err(dev, "unable to add GPIO chip\n");
goto out_iounmap_regs; return ret;
} }
return 0; 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) static int ttl_remove(struct platform_device *pdev)
...@@ -222,8 +203,6 @@ static int ttl_remove(struct platform_device *pdev) ...@@ -222,8 +203,6 @@ static int ttl_remove(struct platform_device *pdev)
return ret; return ret;
} }
iounmap(mod->regs);
kfree(mod);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment