Commit c417299c authored by Jingoo Han's avatar Jingoo Han Committed by Linus Torvalds

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