diff options
author | Devendra Naga <devendra.aaru@gmail.com> | 2012-12-17 19:02:41 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-17 20:15:21 -0500 |
commit | f288cf416ec22de3c5bc18148b6f7620aa32409b (patch) | |
tree | afaac208fbd83543c3166a6c21acb2452e98f96f /drivers/rtc | |
parent | 9ed39bf931cbd95b30755dcb1ad724fe05565c3f (diff) |
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>
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/rtc-davinci.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c index fd95316743c9..07cd03eae606 100644 --- a/drivers/rtc/rtc-davinci.c +++ b/drivers/rtc/rtc-davinci.c | |||
@@ -485,7 +485,7 @@ static int __init davinci_rtc_probe(struct platform_device *pdev) | |||
485 | struct resource *res, *mem; | 485 | struct resource *res, *mem; |
486 | int ret = 0; | 486 | int ret = 0; |
487 | 487 | ||
488 | davinci_rtc = kzalloc(sizeof(struct davinci_rtc), GFP_KERNEL); | 488 | davinci_rtc = devm_kzalloc(&pdev->dev, sizeof(struct davinci_rtc), GFP_KERNEL); |
489 | if (!davinci_rtc) { | 489 | if (!davinci_rtc) { |
490 | dev_dbg(dev, "could not allocate memory for private data\n"); | 490 | dev_dbg(dev, "could not allocate memory for private data\n"); |
491 | return -ENOMEM; | 491 | return -ENOMEM; |
@@ -494,15 +494,13 @@ static int __init davinci_rtc_probe(struct platform_device *pdev) | |||
494 | davinci_rtc->irq = platform_get_irq(pdev, 0); | 494 | davinci_rtc->irq = platform_get_irq(pdev, 0); |
495 | if (davinci_rtc->irq < 0) { | 495 | if (davinci_rtc->irq < 0) { |
496 | dev_err(dev, "no RTC irq\n"); | 496 | dev_err(dev, "no RTC irq\n"); |
497 | ret = davinci_rtc->irq; | 497 | return davinci_rtc->irq; |
498 | goto fail1; | ||
499 | } | 498 | } |
500 | 499 | ||
501 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 500 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
502 | if (!res) { | 501 | if (!res) { |
503 | dev_err(dev, "no mem resource\n"); | 502 | dev_err(dev, "no mem resource\n"); |
504 | ret = -EINVAL; | 503 | return -EINVAL; |
505 | goto fail1; | ||
506 | } | 504 | } |
507 | 505 | ||
508 | davinci_rtc->pbase = res->start; | 506 | davinci_rtc->pbase = res->start; |
@@ -513,8 +511,7 @@ static int __init davinci_rtc_probe(struct platform_device *pdev) | |||
513 | if (!mem) { | 511 | if (!mem) { |
514 | dev_err(dev, "RTC registers at %08x are not free\n", | 512 | dev_err(dev, "RTC registers at %08x are not free\n", |
515 | davinci_rtc->pbase); | 513 | davinci_rtc->pbase); |
516 | ret = -EBUSY; | 514 | return -EBUSY; |
517 | goto fail1; | ||
518 | } | 515 | } |
519 | 516 | ||
520 | davinci_rtc->base = ioremap(davinci_rtc->pbase, davinci_rtc->base_size); | 517 | davinci_rtc->base = ioremap(davinci_rtc->pbase, davinci_rtc->base_size); |
@@ -567,9 +564,6 @@ fail3: | |||
567 | iounmap(davinci_rtc->base); | 564 | iounmap(davinci_rtc->base); |
568 | fail2: | 565 | fail2: |
569 | release_mem_region(davinci_rtc->pbase, davinci_rtc->base_size); | 566 | release_mem_region(davinci_rtc->pbase, davinci_rtc->base_size); |
570 | fail1: | ||
571 | kfree(davinci_rtc); | ||
572 | |||
573 | return ret; | 567 | return ret; |
574 | } | 568 | } |
575 | 569 | ||
@@ -590,8 +584,6 @@ static int __devexit davinci_rtc_remove(struct platform_device *pdev) | |||
590 | 584 | ||
591 | platform_set_drvdata(pdev, NULL); | 585 | platform_set_drvdata(pdev, NULL); |
592 | 586 | ||
593 | kfree(davinci_rtc); | ||
594 | |||
595 | return 0; | 587 | return 0; |
596 | } | 588 | } |
597 | 589 | ||