Commit a47a376f1c025e23e836c0376813c0424de665c2

Authored by Jingoo Han
Committed by Linus Torvalds
1 parent c1879fe80c

rtc: rtc-davinci: use devm_*() functions

Use devm_*() functions to make cleanup paths more simple.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 10 additions and 18 deletions Side-by-side Diff

drivers/rtc/rtc-davinci.c
... ... @@ -506,19 +506,19 @@
506 506 davinci_rtc->pbase = res->start;
507 507 davinci_rtc->base_size = resource_size(res);
508 508  
509   - mem = request_mem_region(davinci_rtc->pbase, davinci_rtc->base_size,
510   - pdev->name);
  509 + mem = devm_request_mem_region(dev, davinci_rtc->pbase,
  510 + davinci_rtc->base_size, pdev->name);
511 511 if (!mem) {
512 512 dev_err(dev, "RTC registers at %08x are not free\n",
513 513 davinci_rtc->pbase);
514 514 return -EBUSY;
515 515 }
516 516  
517   - davinci_rtc->base = ioremap(davinci_rtc->pbase, davinci_rtc->base_size);
  517 + davinci_rtc->base = devm_ioremap(dev, davinci_rtc->pbase,
  518 + davinci_rtc->base_size);
518 519 if (!davinci_rtc->base) {
519 520 dev_err(dev, "unable to ioremap MEM resource\n");
520   - ret = -ENOMEM;
521   - goto fail2;
  521 + return -ENOMEM;
522 522 }
523 523  
524 524 platform_set_drvdata(pdev, davinci_rtc);
... ... @@ -529,7 +529,7 @@
529 529 ret = PTR_ERR(davinci_rtc->rtc);
530 530 dev_err(dev, "unable to register RTC device, err %d\n",
531 531 ret);
532   - goto fail3;
  532 + goto fail1;
533 533 }
534 534  
535 535 rtcif_write(davinci_rtc, PRTCIF_INTFLG_RTCSS, PRTCIF_INTFLG);
536 536  
... ... @@ -539,11 +539,11 @@
539 539 rtcss_write(davinci_rtc, 0, PRTCSS_RTC_CTRL);
540 540 rtcss_write(davinci_rtc, 0, PRTCSS_RTC_CCTRL);
541 541  
542   - ret = request_irq(davinci_rtc->irq, davinci_rtc_interrupt,
  542 + ret = devm_request_irq(dev, davinci_rtc->irq, davinci_rtc_interrupt,
543 543 0, "davinci_rtc", davinci_rtc);
544 544 if (ret < 0) {
545 545 dev_err(dev, "unable to register davinci RTC interrupt\n");
546   - goto fail4;
  546 + goto fail2;
547 547 }
548 548  
549 549 /* Enable interrupts */
550 550  
551 551  
... ... @@ -557,13 +557,10 @@
557 557  
558 558 return 0;
559 559  
560   -fail4:
  560 +fail2:
561 561 rtc_device_unregister(davinci_rtc->rtc);
562   -fail3:
  562 +fail1:
563 563 platform_set_drvdata(pdev, NULL);
564   - iounmap(davinci_rtc->base);
565   -fail2:
566   - release_mem_region(davinci_rtc->pbase, davinci_rtc->base_size);
567 564 return ret;
568 565 }
569 566  
570 567  
... ... @@ -575,12 +572,7 @@
575 572  
576 573 rtcif_write(davinci_rtc, 0, PRTCIF_INTEN);
577 574  
578   - free_irq(davinci_rtc->irq, davinci_rtc);
579   -
580 575 rtc_device_unregister(davinci_rtc->rtc);
581   -
582   - iounmap(davinci_rtc->base);
583   - release_mem_region(davinci_rtc->pbase, davinci_rtc->base_size);
584 576  
585 577 platform_set_drvdata(pdev, NULL);
586 578