提交 87a81420 编写于 作者: J Jingoo Han 提交者: Linus Torvalds

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

Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: NJingoo Han <jg1.han@samsung.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 55d735ef
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册