2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-11-26 19:44:21 +08:00

rtc: rtc-pm8xxx: 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>
This commit is contained in:
Jingoo Han 2013-07-03 15:07:09 -07:00 committed by Linus Torvalds
parent 19b8d8875f
commit c417299ce7

View File

@ -395,7 +395,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
if (pdata != NULL)
rtc_write_enable = pdata->rtc_write_enable;
rtc_dd = kzalloc(sizeof(*rtc_dd), GFP_KERNEL);
rtc_dd = devm_kzalloc(&pdev->dev, sizeof(*rtc_dd), GFP_KERNEL);
if (rtc_dd == NULL) {
dev_err(&pdev->dev, "Unable to allocate memory!\n");
return -ENOMEM;
@ -407,16 +407,14 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
rtc_dd->rtc_alarm_irq = platform_get_irq(pdev, 0);
if (rtc_dd->rtc_alarm_irq < 0) {
dev_err(&pdev->dev, "Alarm IRQ resource absent!\n");
rc = -ENXIO;
goto fail_rtc_enable;
return -ENXIO;
}
rtc_resource = platform_get_resource_byname(pdev, IORESOURCE_IO,
"pmic_rtc_base");
if (!(rtc_resource && rtc_resource->start)) {
dev_err(&pdev->dev, "RTC IO resource absent!\n");
rc = -ENXIO;
goto fail_rtc_enable;
return -ENXIO;
}
rtc_dd->rtc_base = rtc_resource->start;
@ -432,7 +430,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
rc = pm8xxx_read_wrapper(rtc_dd, &ctrl_reg, rtc_dd->rtc_base, 1);
if (rc < 0) {
dev_err(&pdev->dev, "RTC control register read failed!\n");
goto fail_rtc_enable;
return rc;
}
if (!(ctrl_reg & PM8xxx_RTC_ENABLE)) {
@ -442,7 +440,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
if (rc < 0) {
dev_err(&pdev->dev, "Write to RTC control register "
"failed\n");
goto fail_rtc_enable;
return rc;
}
}
@ -453,13 +451,12 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, rtc_dd);
/* Register the RTC device */
rtc_dd->rtc = rtc_device_register("pm8xxx_rtc", &pdev->dev,
rtc_dd->rtc = devm_rtc_device_register(&pdev->dev, "pm8xxx_rtc",
&pm8xxx_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc_dd->rtc)) {
dev_err(&pdev->dev, "%s: RTC registration failed (%ld)\n",
__func__, PTR_ERR(rtc_dd->rtc));
rc = PTR_ERR(rtc_dd->rtc);
goto fail_rtc_enable;
return PTR_ERR(rtc_dd->rtc);
}
/* Request the alarm IRQ */
@ -468,7 +465,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
"pm8xxx_rtc_alarm", rtc_dd);
if (rc < 0) {
dev_err(&pdev->dev, "Request IRQ failed (%d)\n", rc);
goto fail_req_irq;
return rc;
}
device_init_wakeup(&pdev->dev, 1);
@ -476,12 +473,6 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "Probe success !!\n");
return 0;
fail_req_irq:
rtc_device_unregister(rtc_dd->rtc);
fail_rtc_enable:
kfree(rtc_dd);
return rc;
}
static int pm8xxx_rtc_remove(struct platform_device *pdev)
@ -490,8 +481,6 @@ static int pm8xxx_rtc_remove(struct platform_device *pdev)
device_init_wakeup(&pdev->dev, 0);
free_irq(rtc_dd->rtc_alarm_irq, rtc_dd);
rtc_device_unregister(rtc_dd->rtc);
kfree(rtc_dd);
return 0;
}