watchdog: s3c2410_wdt: Use devm_* functions

Use devm_* functions to make cleanup paths more simple.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
This commit is contained in:
Jingoo Han 2013-01-10 11:06:33 +09:00 committed by Wim Van Sebroeck
parent e4504daba1
commit 04ecc7dc8e

View File

@ -309,7 +309,6 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
unsigned int wtcon;
int started = 0;
int ret;
int size;
DBG("%s: probe=%p\n", __func__, pdev);
@ -330,28 +329,20 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
}
/* get the memory region for the watchdog timer */
size = resource_size(wdt_mem);
if (!request_mem_region(wdt_mem->start, size, pdev->name)) {
dev_err(dev, "failed to get memory region\n");
ret = -EBUSY;
goto err;
}
wdt_base = ioremap(wdt_mem->start, size);
wdt_base = devm_request_and_ioremap(dev, wdt_mem);
if (wdt_base == NULL) {
dev_err(dev, "failed to ioremap() region\n");
ret = -EINVAL;
goto err_req;
dev_err(dev, "failed to devm_request_and_ioremap() region\n");
ret = -ENOMEM;
goto err;
}
DBG("probe: mapped wdt_base=%p\n", wdt_base);
wdt_clock = clk_get(&pdev->dev, "watchdog");
wdt_clock = devm_clk_get(dev, "watchdog");
if (IS_ERR(wdt_clock)) {
dev_err(dev, "failed to find watchdog clock source\n");
ret = PTR_ERR(wdt_clock);
goto err_map;
goto err;
}
clk_prepare_enable(wdt_clock);
@ -378,7 +369,8 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
"cannot start\n");
}
ret = request_irq(wdt_irq->start, s3c2410wdt_irq, 0, pdev->name, pdev);
ret = devm_request_irq(dev, wdt_irq->start, s3c2410wdt_irq, 0,
pdev->name, pdev);
if (ret != 0) {
dev_err(dev, "failed to install irq (%d)\n", ret);
goto err_cpufreq;
@ -389,7 +381,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
ret = watchdog_register_device(&s3c2410_wdd);
if (ret) {
dev_err(dev, "cannot register watchdog (%d)\n", ret);
goto err_irq;
goto err_cpufreq;
}
if (tmr_atboot && started == 0) {
@ -414,23 +406,13 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
return 0;
err_irq:
free_irq(wdt_irq->start, pdev);
err_cpufreq:
s3c2410wdt_cpufreq_deregister();
err_clk:
clk_disable_unprepare(wdt_clock);
clk_put(wdt_clock);
wdt_clock = NULL;
err_map:
iounmap(wdt_base);
err_req:
release_mem_region(wdt_mem->start, size);
err:
wdt_irq = NULL;
wdt_mem = NULL;
@ -441,17 +423,11 @@ static int s3c2410wdt_remove(struct platform_device *dev)
{
watchdog_unregister_device(&s3c2410_wdd);
free_irq(wdt_irq->start, dev);
s3c2410wdt_cpufreq_deregister();
clk_disable_unprepare(wdt_clock);
clk_put(wdt_clock);
wdt_clock = NULL;
iounmap(wdt_base);
release_mem_region(wdt_mem->start, resource_size(wdt_mem));
wdt_irq = NULL;
wdt_mem = NULL;
return 0;