Commit 0db29c1d authored by Jingoo Han's avatar Jingoo Han Committed by Linus Torvalds

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

Use devm_*() functions to make cleanup paths more simple.
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 190ab4af
...@@ -231,7 +231,8 @@ static int vt8500_rtc_probe(struct platform_device *pdev) ...@@ -231,7 +231,8 @@ static int vt8500_rtc_probe(struct platform_device *pdev)
return -ENXIO; return -ENXIO;
} }
vt8500_rtc->res = request_mem_region(vt8500_rtc->res->start, vt8500_rtc->res = devm_request_mem_region(&pdev->dev,
vt8500_rtc->res->start,
resource_size(vt8500_rtc->res), resource_size(vt8500_rtc->res),
"vt8500-rtc"); "vt8500-rtc");
if (vt8500_rtc->res == NULL) { if (vt8500_rtc->res == NULL) {
...@@ -239,12 +240,12 @@ static int vt8500_rtc_probe(struct platform_device *pdev) ...@@ -239,12 +240,12 @@ static int vt8500_rtc_probe(struct platform_device *pdev)
return -EBUSY; return -EBUSY;
} }
vt8500_rtc->regbase = ioremap(vt8500_rtc->res->start, vt8500_rtc->regbase = devm_ioremap(&pdev->dev, vt8500_rtc->res->start,
resource_size(vt8500_rtc->res)); resource_size(vt8500_rtc->res));
if (!vt8500_rtc->regbase) { if (!vt8500_rtc->regbase) {
dev_err(&pdev->dev, "Unable to map RTC I/O memory\n"); dev_err(&pdev->dev, "Unable to map RTC I/O memory\n");
ret = -EBUSY; ret = -EBUSY;
goto err_release; goto err_return;
} }
/* Enable RTC and set it to 24-hour mode */ /* Enable RTC and set it to 24-hour mode */
...@@ -257,11 +258,11 @@ static int vt8500_rtc_probe(struct platform_device *pdev) ...@@ -257,11 +258,11 @@ static int vt8500_rtc_probe(struct platform_device *pdev)
ret = PTR_ERR(vt8500_rtc->rtc); ret = PTR_ERR(vt8500_rtc->rtc);
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Failed to register RTC device -> %d\n", ret); "Failed to register RTC device -> %d\n", ret);
goto err_unmap; goto err_return;
} }
ret = request_irq(vt8500_rtc->irq_alarm, vt8500_rtc_irq, 0, ret = devm_request_irq(&pdev->dev, vt8500_rtc->irq_alarm,
"rtc alarm", vt8500_rtc); vt8500_rtc_irq, 0, "rtc alarm", vt8500_rtc);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "can't get irq %i, err %d\n", dev_err(&pdev->dev, "can't get irq %i, err %d\n",
vt8500_rtc->irq_alarm, ret); vt8500_rtc->irq_alarm, ret);
...@@ -272,11 +273,7 @@ static int vt8500_rtc_probe(struct platform_device *pdev) ...@@ -272,11 +273,7 @@ static int vt8500_rtc_probe(struct platform_device *pdev)
err_unreg: err_unreg:
rtc_device_unregister(vt8500_rtc->rtc); rtc_device_unregister(vt8500_rtc->rtc);
err_unmap: err_return:
iounmap(vt8500_rtc->regbase);
err_release:
release_mem_region(vt8500_rtc->res->start,
resource_size(vt8500_rtc->res));
return ret; return ret;
} }
...@@ -284,15 +281,10 @@ static int vt8500_rtc_remove(struct platform_device *pdev) ...@@ -284,15 +281,10 @@ static int vt8500_rtc_remove(struct platform_device *pdev)
{ {
struct vt8500_rtc *vt8500_rtc = platform_get_drvdata(pdev); struct vt8500_rtc *vt8500_rtc = platform_get_drvdata(pdev);
free_irq(vt8500_rtc->irq_alarm, vt8500_rtc);
rtc_device_unregister(vt8500_rtc->rtc); rtc_device_unregister(vt8500_rtc->rtc);
/* Disable alarm matching */ /* Disable alarm matching */
writel(0, vt8500_rtc->regbase + VT8500_RTC_IS); writel(0, vt8500_rtc->regbase + VT8500_RTC_IS);
iounmap(vt8500_rtc->regbase);
release_mem_region(vt8500_rtc->res->start,
resource_size(vt8500_rtc->res));
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
......
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