Commit 87a81420 authored by Jingoo Han's avatar Jingoo Han Committed by Linus Torvalds

rtc: rtc-stmp3xxx: use devm_*() functions

Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 55d735ef
...@@ -227,11 +227,7 @@ static int stmp3xxx_rtc_remove(struct platform_device *pdev) ...@@ -227,11 +227,7 @@ static int stmp3xxx_rtc_remove(struct platform_device *pdev)
writel(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, writel(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN,
rtc_data->io + STMP3XXX_RTC_CTRL_CLR); 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); platform_set_drvdata(pdev, NULL);
iounmap(rtc_data->io);
kfree(rtc_data);
return 0; return 0;
} }
...@@ -242,22 +238,20 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev) ...@@ -242,22 +238,20 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev)
struct resource *r; struct resource *r;
int err; int err;
rtc_data = kzalloc(sizeof *rtc_data, GFP_KERNEL); rtc_data = devm_kzalloc(&pdev->dev, sizeof(*rtc_data), GFP_KERNEL);
if (!rtc_data) if (!rtc_data)
return -ENOMEM; return -ENOMEM;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!r) { if (!r) {
dev_err(&pdev->dev, "failed to get resource\n"); dev_err(&pdev->dev, "failed to get resource\n");
err = -ENXIO; return -ENXIO;
goto out_free;
} }
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) { if (!rtc_data->io) {
dev_err(&pdev->dev, "ioremap failed\n"); dev_err(&pdev->dev, "ioremap failed\n");
err = -EIO; return -EIO;
goto out_free;
} }
rtc_data->irq_alarm = platform_get_irq(pdev, 0); rtc_data->irq_alarm = platform_get_irq(pdev, 0);
...@@ -265,8 +259,7 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev) ...@@ -265,8 +259,7 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev)
if (!(readl(STMP3XXX_RTC_STAT + rtc_data->io) & if (!(readl(STMP3XXX_RTC_STAT + rtc_data->io) &
STMP3XXX_RTC_STAT_RTC_PRESENT)) { STMP3XXX_RTC_STAT_RTC_PRESENT)) {
dev_err(&pdev->dev, "no device onboard\n"); dev_err(&pdev->dev, "no device onboard\n");
err = -ENODEV; return -ENODEV;
goto out_remap;
} }
platform_set_drvdata(pdev, rtc_data); platform_set_drvdata(pdev, rtc_data);
...@@ -281,31 +274,26 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev) ...@@ -281,31 +274,26 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev)
STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, STMP3XXX_RTC_CTRL_ALARM_IRQ_EN,
rtc_data->io + STMP3XXX_RTC_CTRL_CLR); 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); &stmp3xxx_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc_data->rtc)) { if (IS_ERR(rtc_data->rtc)) {
err = PTR_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, err = devm_request_irq(&pdev->dev, rtc_data->irq_alarm,
"RTC alarm", &pdev->dev); stmp3xxx_rtc_interrupt, 0, "RTC alarm", &pdev->dev);
if (err) { if (err) {
dev_err(&pdev->dev, "Cannot claim IRQ%d\n", dev_err(&pdev->dev, "Cannot claim IRQ%d\n",
rtc_data->irq_alarm); rtc_data->irq_alarm);
goto out_irq_alarm; goto out;
} }
stmp3xxx_wdt_register(pdev); stmp3xxx_wdt_register(pdev);
return 0; return 0;
out_irq_alarm: out:
rtc_device_unregister(rtc_data->rtc);
out_remap:
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
iounmap(rtc_data->io);
out_free:
kfree(rtc_data);
return err; return err;
} }
......
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