Commit 621bae79 authored by Hannu Heikkinen's avatar Hannu Heikkinen Committed by Linus Torvalds

drivers/rtc/rtc-tegra.c: clean up probe/remove routines

Use the devres managed resource functions in the probe routine.  Also
affects the remove routine where the previously used free and release
functions are not needed.

The devm_* functions eliminate the need for manual resource releasing and
simplify error handling.  Resources allocated by devm_* are freed
automatically on driver detach.
Signed-off-by: default avatarHannu Heikkinen <ext-hannu.m.heikkinen@nokia.com>
Acked-by: default avatarStephen Warren <swarren@wwwdotorg.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ac2dee59
...@@ -309,7 +309,8 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev) ...@@ -309,7 +309,8 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev)
struct resource *res; struct resource *res;
int ret; int ret;
info = kzalloc(sizeof(struct tegra_rtc_info), GFP_KERNEL); info = devm_kzalloc(&pdev->dev, sizeof(struct tegra_rtc_info),
GFP_KERNEL);
if (!info) if (!info)
return -ENOMEM; return -ENOMEM;
...@@ -317,29 +318,18 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev) ...@@ -317,29 +318,18 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev)
if (!res) { if (!res) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Unable to allocate resources for device.\n"); "Unable to allocate resources for device.\n");
ret = -EBUSY; return -EBUSY;
goto err_free_info;
} }
if (!request_mem_region(res->start, resource_size(res), pdev->name)) { info->rtc_base = devm_request_and_ioremap(&pdev->dev, res);
dev_err(&pdev->dev, if (!info->rtc_base) {
"Unable to request mem region for device.\n"); dev_err(&pdev->dev, "Unable to request mem region and grab IOs for device.\n");
ret = -EBUSY; return -EBUSY;
goto err_free_info;
} }
info->tegra_rtc_irq = platform_get_irq(pdev, 0); info->tegra_rtc_irq = platform_get_irq(pdev, 0);
if (info->tegra_rtc_irq <= 0) { if (info->tegra_rtc_irq <= 0)
ret = -EBUSY; return -EBUSY;
goto err_release_mem_region;
}
info->rtc_base = ioremap_nocache(res->start, resource_size(res));
if (!info->rtc_base) {
dev_err(&pdev->dev, "Unable to grab IOs for device.\n");
ret = -EBUSY;
goto err_release_mem_region;
}
/* set context info. */ /* set context info. */
info->pdev = pdev; info->pdev = pdev;
...@@ -362,11 +352,12 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev) ...@@ -362,11 +352,12 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev)
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Unable to register device (err=%d).\n", "Unable to register device (err=%d).\n",
ret); ret);
goto err_iounmap; return ret;
} }
ret = request_irq(info->tegra_rtc_irq, tegra_rtc_irq_handler, ret = devm_request_irq(&pdev->dev, info->tegra_rtc_irq,
IRQF_TRIGGER_HIGH, "rtc alarm", &pdev->dev); tegra_rtc_irq_handler, IRQF_TRIGGER_HIGH,
"rtc alarm", &pdev->dev);
if (ret) { if (ret) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Unable to request interrupt for device (err=%d).\n", "Unable to request interrupt for device (err=%d).\n",
...@@ -380,12 +371,6 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev) ...@@ -380,12 +371,6 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev)
err_dev_unreg: err_dev_unreg:
rtc_device_unregister(info->rtc_dev); rtc_device_unregister(info->rtc_dev);
err_iounmap:
iounmap(info->rtc_base);
err_release_mem_region:
release_mem_region(res->start, resource_size(res));
err_free_info:
kfree(info);
return ret; return ret;
} }
...@@ -393,17 +378,8 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev) ...@@ -393,17 +378,8 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev)
static int __devexit tegra_rtc_remove(struct platform_device *pdev) static int __devexit tegra_rtc_remove(struct platform_device *pdev)
{ {
struct tegra_rtc_info *info = platform_get_drvdata(pdev); struct tegra_rtc_info *info = platform_get_drvdata(pdev);
struct resource *res;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
return -EBUSY;
free_irq(info->tegra_rtc_irq, &pdev->dev);
rtc_device_unregister(info->rtc_dev); rtc_device_unregister(info->rtc_dev);
iounmap(info->rtc_base);
release_mem_region(res->start, resource_size(res));
kfree(info);
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