rtc: rtc-davinci: use devm_kzalloc()

Use devm_kzalloc() and remove the error path free and the unload free as
devm functions take care of freeing resources.

Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Miguel Aguilar <miguel.aguilar@ridgerun.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Devendra Naga 2012-12-17 16:02:41 -08:00 committed by Linus Torvalds
parent 9ed39bf931
commit f288cf416e
1 changed files with 4 additions and 12 deletions

View File

@ -485,7 +485,7 @@ static int __init davinci_rtc_probe(struct platform_device *pdev)
struct resource *res, *mem; struct resource *res, *mem;
int ret = 0; int ret = 0;
davinci_rtc = kzalloc(sizeof(struct davinci_rtc), GFP_KERNEL); davinci_rtc = devm_kzalloc(&pdev->dev, sizeof(struct davinci_rtc), GFP_KERNEL);
if (!davinci_rtc) { if (!davinci_rtc) {
dev_dbg(dev, "could not allocate memory for private data\n"); dev_dbg(dev, "could not allocate memory for private data\n");
return -ENOMEM; return -ENOMEM;
@ -494,15 +494,13 @@ static int __init davinci_rtc_probe(struct platform_device *pdev)
davinci_rtc->irq = platform_get_irq(pdev, 0); davinci_rtc->irq = platform_get_irq(pdev, 0);
if (davinci_rtc->irq < 0) { if (davinci_rtc->irq < 0) {
dev_err(dev, "no RTC irq\n"); dev_err(dev, "no RTC irq\n");
ret = davinci_rtc->irq; return davinci_rtc->irq;
goto fail1;
} }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { if (!res) {
dev_err(dev, "no mem resource\n"); dev_err(dev, "no mem resource\n");
ret = -EINVAL; return -EINVAL;
goto fail1;
} }
davinci_rtc->pbase = res->start; davinci_rtc->pbase = res->start;
@ -513,8 +511,7 @@ static int __init davinci_rtc_probe(struct platform_device *pdev)
if (!mem) { if (!mem) {
dev_err(dev, "RTC registers at %08x are not free\n", dev_err(dev, "RTC registers at %08x are not free\n",
davinci_rtc->pbase); davinci_rtc->pbase);
ret = -EBUSY; return -EBUSY;
goto fail1;
} }
davinci_rtc->base = ioremap(davinci_rtc->pbase, davinci_rtc->base_size); davinci_rtc->base = ioremap(davinci_rtc->pbase, davinci_rtc->base_size);
@ -567,9 +564,6 @@ static int __init davinci_rtc_probe(struct platform_device *pdev)
iounmap(davinci_rtc->base); iounmap(davinci_rtc->base);
fail2: fail2:
release_mem_region(davinci_rtc->pbase, davinci_rtc->base_size); release_mem_region(davinci_rtc->pbase, davinci_rtc->base_size);
fail1:
kfree(davinci_rtc);
return ret; return ret;
} }
@ -590,8 +584,6 @@ static int __devexit davinci_rtc_remove(struct platform_device *pdev)
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
kfree(davinci_rtc);
return 0; return 0;
} }