Commit 3666eb02 authored by Jingoo Han's avatar Jingoo Han Committed by Wim Van Sebroeck

watchdog: nuc900_wdt: use devm_*() functions

Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent ac1bb694
...@@ -61,7 +61,6 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started " ...@@ -61,7 +61,6 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
"(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
struct nuc900_wdt { struct nuc900_wdt {
struct resource *res;
struct clk *wdt_clock; struct clk *wdt_clock;
struct platform_device *pdev; struct platform_device *pdev;
void __iomem *wdt_base; void __iomem *wdt_base;
...@@ -244,9 +243,11 @@ static struct miscdevice nuc900wdt_miscdev = { ...@@ -244,9 +243,11 @@ static struct miscdevice nuc900wdt_miscdev = {
static int nuc900wdt_probe(struct platform_device *pdev) static int nuc900wdt_probe(struct platform_device *pdev)
{ {
struct resource *res;
int ret = 0; int ret = 0;
nuc900_wdt = kzalloc(sizeof(struct nuc900_wdt), GFP_KERNEL); nuc900_wdt = devm_kzalloc(&pdev->dev, sizeof(*nuc900_wdt),
GFP_KERNEL);
if (!nuc900_wdt) if (!nuc900_wdt)
return -ENOMEM; return -ENOMEM;
...@@ -254,33 +255,20 @@ static int nuc900wdt_probe(struct platform_device *pdev) ...@@ -254,33 +255,20 @@ static int nuc900wdt_probe(struct platform_device *pdev)
spin_lock_init(&nuc900_wdt->wdt_lock); spin_lock_init(&nuc900_wdt->wdt_lock);
nuc900_wdt->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (nuc900_wdt->res == NULL) { if (res == NULL) {
dev_err(&pdev->dev, "no memory resource specified\n"); dev_err(&pdev->dev, "no memory resource specified\n");
ret = -ENOENT; return -ENOENT;
goto err_get;
} }
if (!request_mem_region(nuc900_wdt->res->start, nuc900_wdt->wdt_base = devm_ioremap_resource(&pdev->dev, res);
resource_size(nuc900_wdt->res), pdev->name)) { if (IS_ERR(nuc900_wdt->wdt_base))
dev_err(&pdev->dev, "failed to get memory region\n"); return PTR_ERR(nuc900_wdt->wdt_base);
ret = -ENOENT;
goto err_get;
}
nuc900_wdt->wdt_base = ioremap(nuc900_wdt->res->start,
resource_size(nuc900_wdt->res));
if (nuc900_wdt->wdt_base == NULL) {
dev_err(&pdev->dev, "failed to ioremap() region\n");
ret = -EINVAL;
goto err_req;
}
nuc900_wdt->wdt_clock = clk_get(&pdev->dev, NULL); nuc900_wdt->wdt_clock = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(nuc900_wdt->wdt_clock)) { if (IS_ERR(nuc900_wdt->wdt_clock)) {
dev_err(&pdev->dev, "failed to find watchdog clock source\n"); dev_err(&pdev->dev, "failed to find watchdog clock source\n");
ret = PTR_ERR(nuc900_wdt->wdt_clock); return PTR_ERR(nuc900_wdt->wdt_clock);
goto err_map;
} }
clk_enable(nuc900_wdt->wdt_clock); clk_enable(nuc900_wdt->wdt_clock);
...@@ -298,14 +286,6 @@ static int nuc900wdt_probe(struct platform_device *pdev) ...@@ -298,14 +286,6 @@ static int nuc900wdt_probe(struct platform_device *pdev)
err_clk: err_clk:
clk_disable(nuc900_wdt->wdt_clock); clk_disable(nuc900_wdt->wdt_clock);
clk_put(nuc900_wdt->wdt_clock);
err_map:
iounmap(nuc900_wdt->wdt_base);
err_req:
release_mem_region(nuc900_wdt->res->start,
resource_size(nuc900_wdt->res));
err_get:
kfree(nuc900_wdt);
return ret; return ret;
} }
...@@ -314,14 +294,6 @@ static int nuc900wdt_remove(struct platform_device *pdev) ...@@ -314,14 +294,6 @@ static int nuc900wdt_remove(struct platform_device *pdev)
misc_deregister(&nuc900wdt_miscdev); misc_deregister(&nuc900wdt_miscdev);
clk_disable(nuc900_wdt->wdt_clock); clk_disable(nuc900_wdt->wdt_clock);
clk_put(nuc900_wdt->wdt_clock);
iounmap(nuc900_wdt->wdt_base);
release_mem_region(nuc900_wdt->res->start,
resource_size(nuc900_wdt->res));
kfree(nuc900_wdt);
return 0; return 0;
} }
......
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