]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
watchdog: at32ap700x_wdt: use devm_*() functions
authorJingoo Han <jg1.han@samsung.com>
Tue, 30 Apr 2013 04:59:48 +0000 (13:59 +0900)
committerWim Van Sebroeck <wim@iguana.be>
Thu, 11 Jul 2013 18:52:30 +0000 (20:52 +0200)
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>
drivers/watchdog/at32ap700x_wdt.c

index 7a715e3e6828ee2ede8b80676860d3fc6d280e22..c4cb5526112a230d4e2465f057b71743625549a1 100644 (file)
@@ -321,13 +321,14 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
                return -ENXIO;
        }
 
-       wdt = kzalloc(sizeof(struct wdt_at32ap700x), GFP_KERNEL);
+       wdt = devm_kzalloc(&pdev->dev, sizeof(struct wdt_at32ap700x),
+                       GFP_KERNEL);
        if (!wdt) {
                dev_dbg(&pdev->dev, "no memory for wdt structure\n");
                return -ENOMEM;
        }
 
-       wdt->regs = ioremap(regs->start, resource_size(regs));
+       wdt->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
        if (!wdt->regs) {
                ret = -ENOMEM;
                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)
                dev_info(&pdev->dev, "CPU must be reset with external "
                                "reset or POR due to silicon errata.\n");
                ret = -EIO;
-               goto err_iounmap;
+               goto err_free;
        } else {
                wdt->users = 0;
        }
@@ -375,10 +376,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
 
 err_register:
        platform_set_drvdata(pdev, NULL);
-err_iounmap:
-       iounmap(wdt->regs);
 err_free:
-       kfree(wdt);
        wdt = NULL;
        return ret;
 }
@@ -391,8 +389,6 @@ static int __exit at32_wdt_remove(struct platform_device *pdev)
                        at32_wdt_stop();
 
                misc_deregister(&wdt->miscdev);
-               iounmap(wdt->regs);
-               kfree(wdt);
                wdt = NULL;
                platform_set_drvdata(pdev, NULL);
        }