diff options
author | Viresh Kumar <viresh.kumar@st.com> | 2012-03-12 09:52:15 +0530 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2012-03-27 20:14:34 +0200 |
commit | fb35a5ad5b4b2c3806b52b0159f4d5a0ad205c0f (patch) | |
tree | 194d818dd431c533991441887bed98a8390c4f61 /drivers | |
parent | d2e8919bcfb63b662945d0e5cb9338f0f2229d10 (diff) | |
download | linux-fb35a5ad5b4b2c3806b52b0159f4d5a0ad205c0f.tar.bz2 |
watchdog: sp805: Use devm routines
sp805 driver currently uses normal kzalloc, ioremap, etc routines. This patch
replaces these routines with devm_kzalloc and devm_request_mem_region etc, so
that we don't need to handle freeing of resources for error cases and module
removal routine.
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/watchdog/sp805_wdt.c | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c index 6e751573a2d1..bbb170e50055 100644 --- a/drivers/watchdog/sp805_wdt.c +++ b/drivers/watchdog/sp805_wdt.c @@ -285,32 +285,33 @@ sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id) { int ret = 0; - if (!request_mem_region(adev->res.start, resource_size(&adev->res), - "sp805_wdt")) { + if (!devm_request_mem_region(&adev->dev, adev->res.start, + resource_size(&adev->res), "sp805_wdt")) { dev_warn(&adev->dev, "Failed to get memory region resource\n"); ret = -ENOENT; goto err; } - wdt = kzalloc(sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(&adev->dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) { dev_warn(&adev->dev, "Kzalloc failed\n"); ret = -ENOMEM; - goto err_kzalloc; + goto err; + } + + wdt->base = devm_ioremap(&adev->dev, adev->res.start, + resource_size(&adev->res)); + if (!wdt->base) { + ret = -ENOMEM; + dev_warn(&adev->dev, "ioremap fail\n"); + goto err; } wdt->clk = clk_get(&adev->dev, NULL); if (IS_ERR(wdt->clk)) { dev_warn(&adev->dev, "Clock not found\n"); ret = PTR_ERR(wdt->clk); - goto err_clk_get; - } - - wdt->base = ioremap(adev->res.start, resource_size(&adev->res)); - if (!wdt->base) { - ret = -ENOMEM; - dev_warn(&adev->dev, "ioremap fail\n"); - goto err_ioremap; + goto err; } wdt->adev = adev; @@ -327,14 +328,7 @@ sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id) return 0; err_misc_register: - iounmap(wdt->base); -err_ioremap: clk_put(wdt->clk); -err_clk_get: - kfree(wdt); - wdt = NULL; -err_kzalloc: - release_mem_region(adev->res.start, resource_size(&adev->res)); err: dev_err(&adev->dev, "Probe Failed!!!\n"); return ret; @@ -343,10 +337,7 @@ err: static int __devexit sp805_wdt_remove(struct amba_device *adev) { misc_deregister(&sp805_wdt_miscdev); - iounmap(wdt->base); clk_put(wdt->clk); - kfree(wdt); - release_mem_region(adev->res.start, resource_size(&adev->res)); return 0; } |