Commit 36ac1d24 authored by Linus Walleij's avatar Linus Walleij Committed by Linus Torvalds

drivers/rtc/rtc-coh901331.c: use devm allocation

Allocate memory, region, remap and irq for device state using devm_*
helpers to simplify memory accounting.
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8384dfeb
...@@ -155,14 +155,10 @@ static int __exit coh901331_remove(struct platform_device *pdev) ...@@ -155,14 +155,10 @@ static int __exit coh901331_remove(struct platform_device *pdev)
struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev); struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev);
if (rtap) { if (rtap) {
free_irq(rtap->irq, rtap);
rtc_device_unregister(rtap->rtc); rtc_device_unregister(rtap->rtc);
clk_unprepare(rtap->clk); clk_unprepare(rtap->clk);
clk_put(rtap->clk); clk_put(rtap->clk);
iounmap(rtap->virtbase);
release_mem_region(rtap->phybase, rtap->physize);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
kfree(rtap);
} }
return 0; return 0;
...@@ -175,42 +171,36 @@ static int __init coh901331_probe(struct platform_device *pdev) ...@@ -175,42 +171,36 @@ static int __init coh901331_probe(struct platform_device *pdev)
struct coh901331_port *rtap; struct coh901331_port *rtap;
struct resource *res; struct resource *res;
rtap = kzalloc(sizeof(struct coh901331_port), GFP_KERNEL); rtap = devm_kzalloc(&pdev->dev,
sizeof(struct coh901331_port), GFP_KERNEL);
if (!rtap) if (!rtap)
return -ENOMEM; return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { if (!res)
ret = -ENOENT; return -ENOENT;
goto out_no_resource;
}
rtap->phybase = res->start; rtap->phybase = res->start;
rtap->physize = resource_size(res); rtap->physize = resource_size(res);
if (request_mem_region(rtap->phybase, rtap->physize, if (devm_request_mem_region(&pdev->dev, rtap->phybase, rtap->physize,
"rtc-coh901331") == NULL) { "rtc-coh901331") == NULL)
ret = -EBUSY; return -EBUSY;
goto out_no_memregion;
}
rtap->virtbase = ioremap(rtap->phybase, rtap->physize); rtap->virtbase = devm_ioremap(&pdev->dev, rtap->phybase, rtap->physize);
if (!rtap->virtbase) { if (!rtap->virtbase)
ret = -ENOMEM; return -ENOMEM;
goto out_no_remap;
}
rtap->irq = platform_get_irq(pdev, 0); rtap->irq = platform_get_irq(pdev, 0);
if (request_irq(rtap->irq, coh901331_interrupt, 0, if (devm_request_irq(&pdev->dev, rtap->irq, coh901331_interrupt, 0,
"RTC COH 901 331 Alarm", rtap)) { "RTC COH 901 331 Alarm", rtap))
ret = -EIO; return -EIO;
goto out_no_irq;
}
rtap->clk = clk_get(&pdev->dev, NULL); rtap->clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(rtap->clk)) { if (IS_ERR(rtap->clk)) {
ret = PTR_ERR(rtap->clk); ret = PTR_ERR(rtap->clk);
dev_err(&pdev->dev, "could not get clock\n"); 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 */ /* We enable/disable the clock only to assure it works */
...@@ -236,16 +226,6 @@ static int __init coh901331_probe(struct platform_device *pdev) ...@@ -236,16 +226,6 @@ static int __init coh901331_probe(struct platform_device *pdev)
clk_unprepare(rtap->clk); clk_unprepare(rtap->clk);
out_no_clk_prepenable: out_no_clk_prepenable:
clk_put(rtap->clk); 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; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment