rtc: rtc-mc13xxx: use devm_*() functions
authorJingoo Han <jg1.han@samsung.com>
Mon, 29 Apr 2013 23:20:44 +0000 (16:20 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 30 Apr 2013 01:28:37 +0000 (18:28 -0700)
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>
drivers/rtc/rtc-mc13xxx.c

index 5391b154b43cd4a72272c91bacfaa0b529e919ab..7a8ed27a5f2e1482c95aafab39e2ca7c1544f8eb 100644 (file)
@@ -316,7 +316,7 @@ static int __init mc13xxx_rtc_probe(struct platform_device *pdev)
        struct mc13xxx *mc13xxx;
        int rtcrst_pending;
 
-       priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+       priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
        if (!priv)
                return -ENOMEM;
 
@@ -351,8 +351,8 @@ static int __init mc13xxx_rtc_probe(struct platform_device *pdev)
 
        mc13xxx_unlock(mc13xxx);
 
-       priv->rtc = rtc_device_register(pdev->name,
-                       &pdev->dev, &mc13xxx_rtc_ops, THIS_MODULE);
+       priv->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
+                                       &mc13xxx_rtc_ops, THIS_MODULE);
        if (IS_ERR(priv->rtc)) {
                ret = PTR_ERR(priv->rtc);
 
@@ -372,7 +372,6 @@ err_reset_irq_request:
                mc13xxx_unlock(mc13xxx);
 
                platform_set_drvdata(pdev, NULL);
-               kfree(priv);
        }
 
        return ret;
@@ -384,8 +383,6 @@ static int __exit mc13xxx_rtc_remove(struct platform_device *pdev)
 
        mc13xxx_lock(priv->mc13xxx);
 
-       rtc_device_unregister(priv->rtc);
-
        mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_TODA, priv);
        mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_1HZ, priv);
        mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_RTCRST, priv);
@@ -394,8 +391,6 @@ static int __exit mc13xxx_rtc_remove(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, NULL);
 
-       kfree(priv);
-
        return 0;
 }