提交 04ecc7dc 编写于 作者: J Jingoo Han 提交者: Wim Van Sebroeck

watchdog: s3c2410_wdt: Use devm_* functions

Use devm_* functions to make cleanup paths more simple.
Signed-off-by: NJingoo Han <jg1.han@samsung.com>
Signed-off-by: NWim Van Sebroeck <wim@iguana.be>
上级 e4504dab
...@@ -309,7 +309,6 @@ static int s3c2410wdt_probe(struct platform_device *pdev) ...@@ -309,7 +309,6 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
unsigned int wtcon; unsigned int wtcon;
int started = 0; int started = 0;
int ret; int ret;
int size;
DBG("%s: probe=%p\n", __func__, pdev); DBG("%s: probe=%p\n", __func__, pdev);
...@@ -330,28 +329,20 @@ static int s3c2410wdt_probe(struct platform_device *pdev) ...@@ -330,28 +329,20 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
} }
/* get the memory region for the watchdog timer */ /* get the memory region for the watchdog timer */
wdt_base = devm_request_and_ioremap(dev, wdt_mem);
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);
if (wdt_base == NULL) { if (wdt_base == NULL) {
dev_err(dev, "failed to ioremap() region\n"); dev_err(dev, "failed to devm_request_and_ioremap() region\n");
ret = -EINVAL; ret = -ENOMEM;
goto err_req; goto err;
} }
DBG("probe: mapped wdt_base=%p\n", wdt_base); 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)) { if (IS_ERR(wdt_clock)) {
dev_err(dev, "failed to find watchdog clock source\n"); dev_err(dev, "failed to find watchdog clock source\n");
ret = PTR_ERR(wdt_clock); ret = PTR_ERR(wdt_clock);
goto err_map; goto err;
} }
clk_prepare_enable(wdt_clock); clk_prepare_enable(wdt_clock);
...@@ -378,7 +369,8 @@ static int s3c2410wdt_probe(struct platform_device *pdev) ...@@ -378,7 +369,8 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
"cannot start\n"); "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) { if (ret != 0) {
dev_err(dev, "failed to install irq (%d)\n", ret); dev_err(dev, "failed to install irq (%d)\n", ret);
goto err_cpufreq; goto err_cpufreq;
...@@ -389,7 +381,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) ...@@ -389,7 +381,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
ret = watchdog_register_device(&s3c2410_wdd); ret = watchdog_register_device(&s3c2410_wdd);
if (ret) { if (ret) {
dev_err(dev, "cannot register watchdog (%d)\n", ret); dev_err(dev, "cannot register watchdog (%d)\n", ret);
goto err_irq; goto err_cpufreq;
} }
if (tmr_atboot && started == 0) { if (tmr_atboot && started == 0) {
...@@ -414,23 +406,13 @@ static int s3c2410wdt_probe(struct platform_device *pdev) ...@@ -414,23 +406,13 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
return 0; return 0;
err_irq:
free_irq(wdt_irq->start, pdev);
err_cpufreq: err_cpufreq:
s3c2410wdt_cpufreq_deregister(); s3c2410wdt_cpufreq_deregister();
err_clk: err_clk:
clk_disable_unprepare(wdt_clock); clk_disable_unprepare(wdt_clock);
clk_put(wdt_clock);
wdt_clock = NULL; wdt_clock = NULL;
err_map:
iounmap(wdt_base);
err_req:
release_mem_region(wdt_mem->start, size);
err: err:
wdt_irq = NULL; wdt_irq = NULL;
wdt_mem = NULL; wdt_mem = NULL;
...@@ -441,17 +423,11 @@ static int s3c2410wdt_remove(struct platform_device *dev) ...@@ -441,17 +423,11 @@ static int s3c2410wdt_remove(struct platform_device *dev)
{ {
watchdog_unregister_device(&s3c2410_wdd); watchdog_unregister_device(&s3c2410_wdd);
free_irq(wdt_irq->start, dev);
s3c2410wdt_cpufreq_deregister(); s3c2410wdt_cpufreq_deregister();
clk_disable_unprepare(wdt_clock); clk_disable_unprepare(wdt_clock);
clk_put(wdt_clock);
wdt_clock = NULL; wdt_clock = NULL;
iounmap(wdt_base);
release_mem_region(wdt_mem->start, resource_size(wdt_mem));
wdt_irq = NULL; wdt_irq = NULL;
wdt_mem = NULL; wdt_mem = NULL;
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册