Skip to content

Commit

Permalink
rtc: rtc-mc13xxx: use devm_*() functions
Browse files Browse the repository at this point in the history
Use devm_*() functions to make cleanup paths simpler.

Signed-off-by: Jingoo Han <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Jingoo Han authored and torvalds committed Apr 30, 2013
1 parent 8925e31 commit a379fd2
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions drivers/rtc/rtc-mc13xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand All @@ -372,7 +372,6 @@ static int __init mc13xxx_rtc_probe(struct platform_device *pdev)
mc13xxx_unlock(mc13xxx);

platform_set_drvdata(pdev, NULL);
kfree(priv);
}

return ret;
Expand All @@ -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);
Expand All @@ -394,8 +391,6 @@ static int __exit mc13xxx_rtc_remove(struct platform_device *pdev)

platform_set_drvdata(pdev, NULL);

kfree(priv);

return 0;
}

Expand Down

0 comments on commit a379fd2

Please sign in to comment.