diff options
Diffstat (limited to 'drivers/rtc/rtc-davinci.c')
-rw-r--r-- | drivers/rtc/rtc-davinci.c | 53 |
1 files changed, 19 insertions, 34 deletions
diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c index 14c2109dbaa3..56b73089bb29 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,34 +494,31 @@ 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; |
509 | davinci_rtc->base_size = resource_size(res); | 507 | davinci_rtc->base_size = resource_size(res); |
510 | 508 | ||
511 | mem = request_mem_region(davinci_rtc->pbase, davinci_rtc->base_size, | 509 | mem = devm_request_mem_region(dev, davinci_rtc->pbase, |
512 | pdev->name); | 510 | davinci_rtc->base_size, pdev->name); |
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 = devm_ioremap(dev, davinci_rtc->pbase, |
518 | davinci_rtc->base_size); | ||
521 | if (!davinci_rtc->base) { | 519 | if (!davinci_rtc->base) { |
522 | dev_err(dev, "unable to ioremap MEM resource\n"); | 520 | dev_err(dev, "unable to ioremap MEM resource\n"); |
523 | ret = -ENOMEM; | 521 | return -ENOMEM; |
524 | goto fail2; | ||
525 | } | 522 | } |
526 | 523 | ||
527 | platform_set_drvdata(pdev, davinci_rtc); | 524 | platform_set_drvdata(pdev, davinci_rtc); |
@@ -529,9 +526,10 @@ static int __init davinci_rtc_probe(struct platform_device *pdev) | |||
529 | davinci_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, | 526 | davinci_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, |
530 | &davinci_rtc_ops, THIS_MODULE); | 527 | &davinci_rtc_ops, THIS_MODULE); |
531 | if (IS_ERR(davinci_rtc->rtc)) { | 528 | if (IS_ERR(davinci_rtc->rtc)) { |
532 | dev_err(dev, "unable to register RTC device, err %ld\n", | 529 | ret = PTR_ERR(davinci_rtc->rtc); |
533 | PTR_ERR(davinci_rtc->rtc)); | 530 | dev_err(dev, "unable to register RTC device, err %d\n", |
534 | goto fail3; | 531 | ret); |
532 | goto fail1; | ||
535 | } | 533 | } |
536 | 534 | ||
537 | rtcif_write(davinci_rtc, PRTCIF_INTFLG_RTCSS, PRTCIF_INTFLG); | 535 | rtcif_write(davinci_rtc, PRTCIF_INTFLG_RTCSS, PRTCIF_INTFLG); |
@@ -541,11 +539,11 @@ static int __init davinci_rtc_probe(struct platform_device *pdev) | |||
541 | rtcss_write(davinci_rtc, 0, PRTCSS_RTC_CTRL); | 539 | rtcss_write(davinci_rtc, 0, PRTCSS_RTC_CTRL); |
542 | rtcss_write(davinci_rtc, 0, PRTCSS_RTC_CCTRL); | 540 | rtcss_write(davinci_rtc, 0, PRTCSS_RTC_CCTRL); |
543 | 541 | ||
544 | ret = request_irq(davinci_rtc->irq, davinci_rtc_interrupt, | 542 | ret = devm_request_irq(dev, davinci_rtc->irq, davinci_rtc_interrupt, |
545 | 0, "davinci_rtc", davinci_rtc); | 543 | 0, "davinci_rtc", davinci_rtc); |
546 | if (ret < 0) { | 544 | if (ret < 0) { |
547 | dev_err(dev, "unable to register davinci RTC interrupt\n"); | 545 | dev_err(dev, "unable to register davinci RTC interrupt\n"); |
548 | goto fail4; | 546 | goto fail2; |
549 | } | 547 | } |
550 | 548 | ||
551 | /* Enable interrupts */ | 549 | /* Enable interrupts */ |
@@ -559,20 +557,14 @@ static int __init davinci_rtc_probe(struct platform_device *pdev) | |||
559 | 557 | ||
560 | return 0; | 558 | return 0; |
561 | 559 | ||
562 | fail4: | ||
563 | rtc_device_unregister(davinci_rtc->rtc); | ||
564 | fail3: | ||
565 | platform_set_drvdata(pdev, NULL); | ||
566 | iounmap(davinci_rtc->base); | ||
567 | fail2: | 560 | fail2: |
568 | release_mem_region(davinci_rtc->pbase, davinci_rtc->base_size); | 561 | rtc_device_unregister(davinci_rtc->rtc); |
569 | fail1: | 562 | fail1: |
570 | kfree(davinci_rtc); | 563 | platform_set_drvdata(pdev, NULL); |
571 | |||
572 | return ret; | 564 | return ret; |
573 | } | 565 | } |
574 | 566 | ||
575 | static int __devexit davinci_rtc_remove(struct platform_device *pdev) | 567 | static int davinci_rtc_remove(struct platform_device *pdev) |
576 | { | 568 | { |
577 | struct davinci_rtc *davinci_rtc = platform_get_drvdata(pdev); | 569 | struct davinci_rtc *davinci_rtc = platform_get_drvdata(pdev); |
578 | 570 | ||
@@ -580,23 +572,16 @@ static int __devexit davinci_rtc_remove(struct platform_device *pdev) | |||
580 | 572 | ||
581 | rtcif_write(davinci_rtc, 0, PRTCIF_INTEN); | 573 | rtcif_write(davinci_rtc, 0, PRTCIF_INTEN); |
582 | 574 | ||
583 | free_irq(davinci_rtc->irq, davinci_rtc); | ||
584 | |||
585 | rtc_device_unregister(davinci_rtc->rtc); | 575 | rtc_device_unregister(davinci_rtc->rtc); |
586 | 576 | ||
587 | iounmap(davinci_rtc->base); | ||
588 | release_mem_region(davinci_rtc->pbase, davinci_rtc->base_size); | ||
589 | |||
590 | platform_set_drvdata(pdev, NULL); | 577 | platform_set_drvdata(pdev, NULL); |
591 | 578 | ||
592 | kfree(davinci_rtc); | ||
593 | |||
594 | return 0; | 579 | return 0; |
595 | } | 580 | } |
596 | 581 | ||
597 | static struct platform_driver davinci_rtc_driver = { | 582 | static struct platform_driver davinci_rtc_driver = { |
598 | .probe = davinci_rtc_probe, | 583 | .probe = davinci_rtc_probe, |
599 | .remove = __devexit_p(davinci_rtc_remove), | 584 | .remove = davinci_rtc_remove, |
600 | .driver = { | 585 | .driver = { |
601 | .name = "rtc_davinci", | 586 | .name = "rtc_davinci", |
602 | .owner = THIS_MODULE, | 587 | .owner = THIS_MODULE, |