Commit 30c65b22 authored by Guenter Roeck's avatar Guenter Roeck

watchdog: coh901327_wdt: Use devm_ioremap_resource to map resources

Map resources using devm_ioremap_resource() to simplify error handling.
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 14da8d42
...@@ -68,8 +68,6 @@ ...@@ -68,8 +68,6 @@
/* Default timeout in seconds = 1 minute */ /* Default timeout in seconds = 1 minute */
static unsigned int margin = 60; static unsigned int margin = 60;
static resource_size_t phybase;
static resource_size_t physize;
static int irq; static int irq;
static void __iomem *virtbase; static void __iomem *virtbase;
static struct device *parent; static struct device *parent;
...@@ -248,8 +246,6 @@ static int __exit coh901327_remove(struct platform_device *pdev) ...@@ -248,8 +246,6 @@ static int __exit coh901327_remove(struct platform_device *pdev)
free_irq(irq, pdev); free_irq(irq, pdev);
clk_disable_unprepare(clk); clk_disable_unprepare(clk);
clk_put(clk); clk_put(clk);
iounmap(virtbase);
release_mem_region(phybase, physize);
return 0; return 0;
} }
...@@ -259,30 +255,18 @@ static int __init coh901327_probe(struct platform_device *pdev) ...@@ -259,30 +255,18 @@ static int __init coh901327_probe(struct platform_device *pdev)
u16 val; u16 val;
struct resource *res; struct resource *res;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
return -ENOENT;
parent = &pdev->dev; parent = &pdev->dev;
physize = resource_size(res);
phybase = res->start;
if (request_mem_region(phybase, physize, DRV_NAME) == NULL) {
ret = -EBUSY;
goto out;
}
virtbase = ioremap(phybase, physize); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!virtbase) { virtbase = devm_ioremap_resource(&pdev->dev, res);
ret = -ENOMEM; if (IS_ERR(virtbase))
goto out_no_remap; return PTR_ERR(virtbase);
}
clk = clk_get(&pdev->dev, NULL); clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
ret = PTR_ERR(clk); ret = PTR_ERR(clk);
dev_err(&pdev->dev, "could not get clock\n"); dev_err(&pdev->dev, "could not get clock\n");
goto out_no_clk; return ret;
} }
ret = clk_prepare_enable(clk); ret = clk_prepare_enable(clk);
if (ret) { if (ret) {
...@@ -353,11 +337,6 @@ static int __init coh901327_probe(struct platform_device *pdev) ...@@ -353,11 +337,6 @@ static int __init coh901327_probe(struct platform_device *pdev)
clk_disable_unprepare(clk); clk_disable_unprepare(clk);
out_no_clk_enable: out_no_clk_enable:
clk_put(clk); clk_put(clk);
out_no_clk:
iounmap(virtbase);
out_no_remap:
release_mem_region(phybase, SZ_4K);
out:
return ret; return ret;
} }
......
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