rtc: rtc-msm6242: use devm_*() functions
Use devm_*() functions to make cleanup paths simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
a379fd2458
commit
c40dcf6e8c
@ -194,30 +194,28 @@ static const struct rtc_class_ops msm6242_rtc_ops = {
|
|||||||
.set_time = msm6242_set_time,
|
.set_time = msm6242_set_time,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init msm6242_rtc_probe(struct platform_device *dev)
|
static int __init msm6242_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
struct msm6242_priv *priv;
|
struct msm6242_priv *priv;
|
||||||
struct rtc_device *rtc;
|
struct rtc_device *rtc;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
res = platform_get_resource(dev, IORESOURCE_MEM, 0);
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
if (!res)
|
if (!res)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
|
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
|
||||||
if (!priv)
|
if (!priv)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
priv->regs = ioremap(res->start, resource_size(res));
|
priv->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
|
||||||
if (!priv->regs) {
|
if (!priv->regs)
|
||||||
error = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto out_free_priv;
|
platform_set_drvdata(pdev, priv);
|
||||||
}
|
|
||||||
platform_set_drvdata(dev, priv);
|
|
||||||
|
|
||||||
rtc = rtc_device_register("rtc-msm6242", &dev->dev, &msm6242_rtc_ops,
|
rtc = devm_rtc_device_register(&pdev->dev, "rtc-msm6242",
|
||||||
THIS_MODULE);
|
&msm6242_rtc_ops, THIS_MODULE);
|
||||||
if (IS_ERR(rtc)) {
|
if (IS_ERR(rtc)) {
|
||||||
error = PTR_ERR(rtc);
|
error = PTR_ERR(rtc);
|
||||||
goto out_unmap;
|
goto out_unmap;
|
||||||
@ -227,20 +225,12 @@ static int __init msm6242_rtc_probe(struct platform_device *dev)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_unmap:
|
out_unmap:
|
||||||
platform_set_drvdata(dev, NULL);
|
platform_set_drvdata(pdev, NULL);
|
||||||
iounmap(priv->regs);
|
|
||||||
out_free_priv:
|
|
||||||
kfree(priv);
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __exit msm6242_rtc_remove(struct platform_device *dev)
|
static int __exit msm6242_rtc_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct msm6242_priv *priv = platform_get_drvdata(dev);
|
|
||||||
|
|
||||||
rtc_device_unregister(priv->rtc);
|
|
||||||
iounmap(priv->regs);
|
|
||||||
kfree(priv);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user