summaryrefslogtreecommitdiff
path: root/drivers/rtc/rtc-stmp3xxx.c
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2013-04-30 03:20:55 +0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-30 05:28:39 +0400
commit87a81420873d031dc387c6d1c8cefa067b539fa2 (patch)
tree3d170ba5648e1adc48569c17ef22f6b0548529f1 /drivers/rtc/rtc-stmp3xxx.c
parent55d735efd0132619b1887c4b5a8dcf2156f35216 (diff)
downloadlinux-87a81420873d031dc387c6d1c8cefa067b539fa2.tar.xz
rtc: rtc-stmp3xxx: 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>
Diffstat (limited to 'drivers/rtc/rtc-stmp3xxx.c')
-rw-r--r--drivers/rtc/rtc-stmp3xxx.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c
index 98f0d3c30738..0930f275b2dd 100644
--- a/drivers/rtc/rtc-stmp3xxx.c
+++ b/drivers/rtc/rtc-stmp3xxx.c
@@ -227,11 +227,7 @@ static int stmp3xxx_rtc_remove(struct platform_device *pdev)
writel(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN,
rtc_data->io + STMP3XXX_RTC_CTRL_CLR);
- free_irq(rtc_data->irq_alarm, &pdev->dev);
- rtc_device_unregister(rtc_data->rtc);
platform_set_drvdata(pdev, NULL);
- iounmap(rtc_data->io);
- kfree(rtc_data);
return 0;
}
@@ -242,22 +238,20 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev)
struct resource *r;
int err;
- rtc_data = kzalloc(sizeof *rtc_data, GFP_KERNEL);
+ rtc_data = devm_kzalloc(&pdev->dev, sizeof(*rtc_data), GFP_KERNEL);
if (!rtc_data)
return -ENOMEM;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!r) {
dev_err(&pdev->dev, "failed to get resource\n");
- err = -ENXIO;
- goto out_free;
+ return -ENXIO;
}
- rtc_data->io = ioremap(r->start, resource_size(r));
+ rtc_data->io = devm_ioremap(&pdev->dev, r->start, resource_size(r));
if (!rtc_data->io) {
dev_err(&pdev->dev, "ioremap failed\n");
- err = -EIO;
- goto out_free;
+ return -EIO;
}
rtc_data->irq_alarm = platform_get_irq(pdev, 0);
@@ -265,8 +259,7 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev)
if (!(readl(STMP3XXX_RTC_STAT + rtc_data->io) &
STMP3XXX_RTC_STAT_RTC_PRESENT)) {
dev_err(&pdev->dev, "no device onboard\n");
- err = -ENODEV;
- goto out_remap;
+ return -ENODEV;
}
platform_set_drvdata(pdev, rtc_data);
@@ -281,31 +274,26 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev)
STMP3XXX_RTC_CTRL_ALARM_IRQ_EN,
rtc_data->io + STMP3XXX_RTC_CTRL_CLR);
- rtc_data->rtc = rtc_device_register(pdev->name, &pdev->dev,
+ rtc_data->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
&stmp3xxx_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc_data->rtc)) {
err = PTR_ERR(rtc_data->rtc);
- goto out_remap;
+ goto out;
}
- err = request_irq(rtc_data->irq_alarm, stmp3xxx_rtc_interrupt, 0,
- "RTC alarm", &pdev->dev);
+ err = devm_request_irq(&pdev->dev, rtc_data->irq_alarm,
+ stmp3xxx_rtc_interrupt, 0, "RTC alarm", &pdev->dev);
if (err) {
dev_err(&pdev->dev, "Cannot claim IRQ%d\n",
rtc_data->irq_alarm);
- goto out_irq_alarm;
+ goto out;
}
stmp3xxx_wdt_register(pdev);
return 0;
-out_irq_alarm:
- rtc_device_unregister(rtc_data->rtc);
-out_remap:
+out:
platform_set_drvdata(pdev, NULL);
- iounmap(rtc_data->io);
-out_free:
- kfree(rtc_data);
return err;
}