diff options
author | Viresh Kumar <viresh.kumar@st.com> | 2012-03-12 00:22:15 -0400 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2012-03-27 14:14:34 -0400 |
commit | fb35a5ad5b4b2c3806b52b0159f4d5a0ad205c0f (patch) | |
tree | 194d818dd431c533991441887bed98a8390c4f61 /drivers/watchdog | |
parent | d2e8919bcfb63b662945d0e5cb9338f0f2229d10 (diff) |
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/watchdog')
-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) | |||
285 | { | 285 | { |
286 | int ret = 0; | 286 | int ret = 0; |
287 | 287 | ||
288 | if (!request_mem_region(adev->res.start, resource_size(&adev->res), | 288 | if (!devm_request_mem_region(&adev->dev, adev->res.start, |
289 | "sp805_wdt")) { | 289 | resource_size(&adev->res), "sp805_wdt")) { |
290 | dev_warn(&adev->dev, "Failed to get memory region resource\n"); | 290 | dev_warn(&adev->dev, "Failed to get memory region resource\n"); |
291 | ret = -ENOENT; | 291 | ret = -ENOENT; |
292 | goto err; | 292 | goto err; |
293 | } | 293 | } |
294 | 294 | ||
295 | wdt = kzalloc(sizeof(*wdt), GFP_KERNEL); | 295 | wdt = devm_kzalloc(&adev->dev, sizeof(*wdt), GFP_KERNEL); |
296 | if (!wdt) { | 296 | if (!wdt) { |
297 | dev_warn(&adev->dev, "Kzalloc failed\n"); | 297 | dev_warn(&adev->dev, "Kzalloc failed\n"); |
298 | ret = -ENOMEM; | 298 | ret = -ENOMEM; |
299 | goto err_kzalloc; | 299 | goto err; |
300 | } | ||
301 | |||
302 | wdt->base = devm_ioremap(&adev->dev, adev->res.start, | ||
303 | resource_size(&adev->res)); | ||
304 | if (!wdt->base) { | ||
305 | ret = -ENOMEM; | ||
306 | dev_warn(&adev->dev, "ioremap fail\n"); | ||
307 | goto err; | ||
300 | } | 308 | } |
301 | 309 | ||
302 | wdt->clk = clk_get(&adev->dev, NULL); | 310 | wdt->clk = clk_get(&adev->dev, NULL); |
303 | if (IS_ERR(wdt->clk)) { | 311 | if (IS_ERR(wdt->clk)) { |
304 | dev_warn(&adev->dev, "Clock not found\n"); | 312 | dev_warn(&adev->dev, "Clock not found\n"); |
305 | ret = PTR_ERR(wdt->clk); | 313 | ret = PTR_ERR(wdt->clk); |
306 | goto err_clk_get; | 314 | goto err; |
307 | } | ||
308 | |||
309 | wdt->base = ioremap(adev->res.start, resource_size(&adev->res)); | ||
310 | if (!wdt->base) { | ||
311 | ret = -ENOMEM; | ||
312 | dev_warn(&adev->dev, "ioremap fail\n"); | ||
313 | goto err_ioremap; | ||
314 | } | 315 | } |
315 | 316 | ||
316 | wdt->adev = adev; | 317 | wdt->adev = adev; |
@@ -327,14 +328,7 @@ sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id) | |||
327 | return 0; | 328 | return 0; |
328 | 329 | ||
329 | err_misc_register: | 330 | err_misc_register: |
330 | iounmap(wdt->base); | ||
331 | err_ioremap: | ||
332 | clk_put(wdt->clk); | 331 | clk_put(wdt->clk); |
333 | err_clk_get: | ||
334 | kfree(wdt); | ||
335 | wdt = NULL; | ||
336 | err_kzalloc: | ||
337 | release_mem_region(adev->res.start, resource_size(&adev->res)); | ||
338 | err: | 332 | err: |
339 | dev_err(&adev->dev, "Probe Failed!!!\n"); | 333 | dev_err(&adev->dev, "Probe Failed!!!\n"); |
340 | return ret; | 334 | return ret; |
@@ -343,10 +337,7 @@ err: | |||
343 | static int __devexit sp805_wdt_remove(struct amba_device *adev) | 337 | static int __devexit sp805_wdt_remove(struct amba_device *adev) |
344 | { | 338 | { |
345 | misc_deregister(&sp805_wdt_miscdev); | 339 | misc_deregister(&sp805_wdt_miscdev); |
346 | iounmap(wdt->base); | ||
347 | clk_put(wdt->clk); | 340 | clk_put(wdt->clk); |
348 | kfree(wdt); | ||
349 | release_mem_region(adev->res.start, resource_size(&adev->res)); | ||
350 | 341 | ||
351 | return 0; | 342 | return 0; |
352 | } | 343 | } |