Commit 58c181c8 authored by Sangjung Woo's avatar Sangjung Woo Committed by Linus Torvalds

drivers/rtc/rtc-pl030.c: use devm_kzalloc() instead of kmalloc()

In order to be free automatically and make the cleanup paths more simple,
use devm_kzalloc() instead of kmalloc().
Signed-off-by: default avatarSangjung Woo <sangjung.woo@samsung.com>
Cc: Joe Perches <joe@perches.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1fbc4c4d
...@@ -106,7 +106,7 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id) ...@@ -106,7 +106,7 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id)
if (ret) if (ret)
goto err_req; goto err_req;
rtc = kmalloc(sizeof(*rtc), GFP_KERNEL); rtc = devm_kzalloc(&dev->dev, sizeof(*rtc), GFP_KERNEL);
if (!rtc) { if (!rtc) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_rtc; goto err_rtc;
...@@ -115,7 +115,7 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id) ...@@ -115,7 +115,7 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id)
rtc->base = ioremap(dev->res.start, resource_size(&dev->res)); rtc->base = ioremap(dev->res.start, resource_size(&dev->res));
if (!rtc->base) { if (!rtc->base) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_map; goto err_rtc;
} }
__raw_writel(0, rtc->base + RTC_CR); __raw_writel(0, rtc->base + RTC_CR);
...@@ -141,8 +141,6 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id) ...@@ -141,8 +141,6 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id)
free_irq(dev->irq[0], rtc); free_irq(dev->irq[0], rtc);
err_irq: err_irq:
iounmap(rtc->base); iounmap(rtc->base);
err_map:
kfree(rtc);
err_rtc: err_rtc:
amba_release_regions(dev); amba_release_regions(dev);
err_req: err_req:
...@@ -158,7 +156,6 @@ static int pl030_remove(struct amba_device *dev) ...@@ -158,7 +156,6 @@ static int pl030_remove(struct amba_device *dev)
free_irq(dev->irq[0], rtc); free_irq(dev->irq[0], rtc);
rtc_device_unregister(rtc->rtc); rtc_device_unregister(rtc->rtc);
iounmap(rtc->base); iounmap(rtc->base);
kfree(rtc);
amba_release_regions(dev); amba_release_regions(dev);
return 0; return 0;
......
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