aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-s3c.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-s3c.c')
-rw-r--r--drivers/rtc/rtc-s3c.c52
1 files changed, 9 insertions, 43 deletions
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index a7a2a998fa91..4bd9414aee65 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -47,8 +47,6 @@ struct s3c_rtc_drv_data {
47/* I have yet to find an S3C implementation with more than one 47/* I have yet to find an S3C implementation with more than one
48 * of these rtc blocks in */ 48 * of these rtc blocks in */
49 49
50static struct resource *s3c_rtc_mem;
51
52static struct clk *rtc_clk; 50static struct clk *rtc_clk;
53static void __iomem *s3c_rtc_base; 51static void __iomem *s3c_rtc_base;
54static int s3c_rtc_alarmno = NO_IRQ; 52static int s3c_rtc_alarmno = NO_IRQ;
@@ -427,21 +425,13 @@ static int __devexit s3c_rtc_remove(struct platform_device *dev)
427{ 425{
428 struct rtc_device *rtc = platform_get_drvdata(dev); 426 struct rtc_device *rtc = platform_get_drvdata(dev);
429 427
430 free_irq(s3c_rtc_alarmno, rtc);
431 free_irq(s3c_rtc_tickno, rtc);
432
433 platform_set_drvdata(dev, NULL); 428 platform_set_drvdata(dev, NULL);
434 rtc_device_unregister(rtc); 429 rtc_device_unregister(rtc);
435 430
436 s3c_rtc_setaie(&dev->dev, 0); 431 s3c_rtc_setaie(&dev->dev, 0);
437 432
438 clk_put(rtc_clk);
439 rtc_clk = NULL; 433 rtc_clk = NULL;
440 434
441 iounmap(s3c_rtc_base);
442 release_resource(s3c_rtc_mem);
443 kfree(s3c_rtc_mem);
444
445 return 0; 435 return 0;
446} 436}
447 437
@@ -496,28 +486,18 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
496 return -ENOENT; 486 return -ENOENT;
497 } 487 }
498 488
499 s3c_rtc_mem = request_mem_region(res->start, resource_size(res), 489 s3c_rtc_base = devm_request_and_ioremap(&pdev->dev, res);
500 pdev->name);
501
502 if (s3c_rtc_mem == NULL) {
503 dev_err(&pdev->dev, "failed to reserve memory region\n");
504 ret = -ENOENT;
505 goto err_nores;
506 }
507
508 s3c_rtc_base = ioremap(res->start, resource_size(res));
509 if (s3c_rtc_base == NULL) { 490 if (s3c_rtc_base == NULL) {
510 dev_err(&pdev->dev, "failed ioremap()\n"); 491 dev_err(&pdev->dev, "failed to ioremap memory region\n");
511 ret = -EINVAL; 492 return -EINVAL;
512 goto err_nomap;
513 } 493 }
514 494
515 rtc_clk = clk_get(&pdev->dev, "rtc"); 495 rtc_clk = devm_clk_get(&pdev->dev, "rtc");
516 if (IS_ERR(rtc_clk)) { 496 if (IS_ERR(rtc_clk)) {
517 dev_err(&pdev->dev, "failed to find rtc clock source\n"); 497 dev_err(&pdev->dev, "failed to find rtc clock source\n");
518 ret = PTR_ERR(rtc_clk); 498 ret = PTR_ERR(rtc_clk);
519 rtc_clk = NULL; 499 rtc_clk = NULL;
520 goto err_clk; 500 return ret;
521 } 501 }
522 502
523 clk_enable(rtc_clk); 503 clk_enable(rtc_clk);
@@ -576,28 +556,24 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
576 556
577 s3c_rtc_setfreq(&pdev->dev, 1); 557 s3c_rtc_setfreq(&pdev->dev, 1);
578 558
579 ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq, 559 ret = devm_request_irq(&pdev->dev, s3c_rtc_alarmno, s3c_rtc_alarmirq,
580 0, "s3c2410-rtc alarm", rtc); 560 0, "s3c2410-rtc alarm", rtc);
581 if (ret) { 561 if (ret) {
582 dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); 562 dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret);
583 goto err_alarm_irq; 563 goto err_alarm_irq;
584 } 564 }
585 565
586 ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq, 566 ret = devm_request_irq(&pdev->dev, s3c_rtc_tickno, s3c_rtc_tickirq,
587 0, "s3c2410-rtc tick", rtc); 567 0, "s3c2410-rtc tick", rtc);
588 if (ret) { 568 if (ret) {
589 dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); 569 dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret);
590 free_irq(s3c_rtc_alarmno, rtc); 570 goto err_alarm_irq;
591 goto err_tick_irq;
592 } 571 }
593 572
594 clk_disable(rtc_clk); 573 clk_disable(rtc_clk);
595 574
596 return 0; 575 return 0;
597 576
598 err_tick_irq:
599 free_irq(s3c_rtc_alarmno, rtc);
600
601 err_alarm_irq: 577 err_alarm_irq:
602 platform_set_drvdata(pdev, NULL); 578 platform_set_drvdata(pdev, NULL);
603 rtc_device_unregister(rtc); 579 rtc_device_unregister(rtc);
@@ -605,15 +581,7 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
605 err_nortc: 581 err_nortc:
606 s3c_rtc_enable(pdev, 0); 582 s3c_rtc_enable(pdev, 0);
607 clk_disable(rtc_clk); 583 clk_disable(rtc_clk);
608 clk_put(rtc_clk);
609 584
610 err_clk:
611 iounmap(s3c_rtc_base);
612
613 err_nomap:
614 release_resource(s3c_rtc_mem);
615
616 err_nores:
617 return ret; 585 return ret;
618} 586}
619 587
@@ -695,8 +663,6 @@ static const struct of_device_id s3c_rtc_dt_match[] = {
695 {}, 663 {},
696}; 664};
697MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match); 665MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match);
698#else
699#define s3c_rtc_dt_match NULL
700#endif 666#endif
701 667
702static struct platform_device_id s3c_rtc_driver_ids[] = { 668static struct platform_device_id s3c_rtc_driver_ids[] = {
@@ -727,7 +693,7 @@ static struct platform_driver s3c_rtc_driver = {
727 .driver = { 693 .driver = {
728 .name = "s3c-rtc", 694 .name = "s3c-rtc",
729 .owner = THIS_MODULE, 695 .owner = THIS_MODULE,
730 .of_match_table = s3c_rtc_dt_match, 696 .of_match_table = of_match_ptr(s3c_rtc_dt_match),
731 }, 697 },
732}; 698};
733 699