]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
drivers/rtc/rtc-coh901331.c: use devm allocation
authorLinus Walleij <linus.walleij@linaro.org>
Mon, 30 Jul 2012 21:41:32 +0000 (14:41 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 31 Jul 2012 00:25:17 +0000 (17:25 -0700)
Allocate memory, region, remap and irq for device state using devm_*
helpers to simplify memory accounting.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/rtc/rtc-coh901331.c

index 58665029d6f355b32e7a8641cbc7a8aca8469d9f..76b2156d3c62252c80aec1eacce8fe0684950d75 100644 (file)
@@ -155,14 +155,10 @@ static int __exit coh901331_remove(struct platform_device *pdev)
        struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev);
 
        if (rtap) {
-               free_irq(rtap->irq, rtap);
                rtc_device_unregister(rtap->rtc);
                clk_unprepare(rtap->clk);
                clk_put(rtap->clk);
-               iounmap(rtap->virtbase);
-               release_mem_region(rtap->phybase, rtap->physize);
                platform_set_drvdata(pdev, NULL);
-               kfree(rtap);
        }
 
        return 0;
@@ -175,42 +171,36 @@ static int __init coh901331_probe(struct platform_device *pdev)
        struct coh901331_port *rtap;
        struct resource *res;
 
-       rtap = kzalloc(sizeof(struct coh901331_port), GFP_KERNEL);
+       rtap = devm_kzalloc(&pdev->dev,
+                           sizeof(struct coh901331_port), GFP_KERNEL);
        if (!rtap)
                return -ENOMEM;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!res) {
-               ret = -ENOENT;
-               goto out_no_resource;
-       }
+       if (!res)
+               return -ENOENT;
+
        rtap->phybase = res->start;
        rtap->physize = resource_size(res);
 
-       if (request_mem_region(rtap->phybase, rtap->physize,
-                              "rtc-coh901331") == NULL) {
-               ret = -EBUSY;
-               goto out_no_memregion;
-       }
+       if (devm_request_mem_region(&pdev->dev, rtap->phybase, rtap->physize,
+                                   "rtc-coh901331") == NULL)
+               return -EBUSY;
 
-       rtap->virtbase = ioremap(rtap->phybase, rtap->physize);
-       if (!rtap->virtbase) {
-               ret = -ENOMEM;
-               goto out_no_remap;
-       }
+       rtap->virtbase = devm_ioremap(&pdev->dev, rtap->phybase, rtap->physize);
+       if (!rtap->virtbase)
+               return -ENOMEM;
 
        rtap->irq = platform_get_irq(pdev, 0);
-       if (request_irq(rtap->irq, coh901331_interrupt, 0,
-                       "RTC COH 901 331 Alarm", rtap)) {
-               ret = -EIO;
-               goto out_no_irq;
-       }
+       if (devm_request_irq(&pdev->dev, rtap->irq, coh901331_interrupt, 0,
+                            "RTC COH 901 331 Alarm", rtap))
+               return -EIO;
 
        rtap->clk = clk_get(&pdev->dev, NULL);
        if (IS_ERR(rtap->clk)) {
                ret = PTR_ERR(rtap->clk);
                dev_err(&pdev->dev, "could not get clock\n");
-               goto out_no_clk;
+               return ret;
        }
 
        /* We enable/disable the clock only to assure it works */
@@ -236,16 +226,6 @@ static int __init coh901331_probe(struct platform_device *pdev)
        clk_unprepare(rtap->clk);
  out_no_clk_prepenable:
        clk_put(rtap->clk);
- out_no_clk:
-       free_irq(rtap->irq, rtap);
- out_no_irq:
-       iounmap(rtap->virtbase);
- out_no_remap:
-       platform_set_drvdata(pdev, NULL);
- out_no_memregion:
-       release_mem_region(rtap->phybase, SZ_4K);
- out_no_resource:
-       kfree(rtap);
        return ret;
 }