diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-04-30 00:59:48 -0400 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2013-07-11 14:52:30 -0400 |
commit | a7960784e9ddd526e4fb791bc23e4fe6f039c28e (patch) | |
tree | 42372443f2fca0d09d37414edb68226a224e0cab /drivers/watchdog | |
parent | 6d128e1e72bf082542e85f72e6b7ddd704193588 (diff) |
watchdog: at32ap700x_wdt: use devm_*() functions
Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r-- | drivers/watchdog/at32ap700x_wdt.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/watchdog/at32ap700x_wdt.c b/drivers/watchdog/at32ap700x_wdt.c index 7a715e3e6828..c4cb5526112a 100644 --- a/drivers/watchdog/at32ap700x_wdt.c +++ b/drivers/watchdog/at32ap700x_wdt.c | |||
@@ -321,13 +321,14 @@ static int __init at32_wdt_probe(struct platform_device *pdev) | |||
321 | return -ENXIO; | 321 | return -ENXIO; |
322 | } | 322 | } |
323 | 323 | ||
324 | wdt = kzalloc(sizeof(struct wdt_at32ap700x), GFP_KERNEL); | 324 | wdt = devm_kzalloc(&pdev->dev, sizeof(struct wdt_at32ap700x), |
325 | GFP_KERNEL); | ||
325 | if (!wdt) { | 326 | if (!wdt) { |
326 | dev_dbg(&pdev->dev, "no memory for wdt structure\n"); | 327 | dev_dbg(&pdev->dev, "no memory for wdt structure\n"); |
327 | return -ENOMEM; | 328 | return -ENOMEM; |
328 | } | 329 | } |
329 | 330 | ||
330 | wdt->regs = ioremap(regs->start, resource_size(regs)); | 331 | wdt->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs)); |
331 | if (!wdt->regs) { | 332 | if (!wdt->regs) { |
332 | ret = -ENOMEM; | 333 | ret = -ENOMEM; |
333 | dev_dbg(&pdev->dev, "could not map I/O memory\n"); | 334 | dev_dbg(&pdev->dev, "could not map I/O memory\n"); |
@@ -342,7 +343,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev) | |||
342 | dev_info(&pdev->dev, "CPU must be reset with external " | 343 | dev_info(&pdev->dev, "CPU must be reset with external " |
343 | "reset or POR due to silicon errata.\n"); | 344 | "reset or POR due to silicon errata.\n"); |
344 | ret = -EIO; | 345 | ret = -EIO; |
345 | goto err_iounmap; | 346 | goto err_free; |
346 | } else { | 347 | } else { |
347 | wdt->users = 0; | 348 | wdt->users = 0; |
348 | } | 349 | } |
@@ -375,10 +376,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev) | |||
375 | 376 | ||
376 | err_register: | 377 | err_register: |
377 | platform_set_drvdata(pdev, NULL); | 378 | platform_set_drvdata(pdev, NULL); |
378 | err_iounmap: | ||
379 | iounmap(wdt->regs); | ||
380 | err_free: | 379 | err_free: |
381 | kfree(wdt); | ||
382 | wdt = NULL; | 380 | wdt = NULL; |
383 | return ret; | 381 | return ret; |
384 | } | 382 | } |
@@ -391,8 +389,6 @@ static int __exit at32_wdt_remove(struct platform_device *pdev) | |||
391 | at32_wdt_stop(); | 389 | at32_wdt_stop(); |
392 | 390 | ||
393 | misc_deregister(&wdt->miscdev); | 391 | misc_deregister(&wdt->miscdev); |
394 | iounmap(wdt->regs); | ||
395 | kfree(wdt); | ||
396 | wdt = NULL; | 392 | wdt = NULL; |
397 | platform_set_drvdata(pdev, NULL); | 393 | platform_set_drvdata(pdev, NULL); |
398 | } | 394 | } |