diff options
Diffstat (limited to 'drivers/rtc/rtc-s3c.c')
| -rw-r--r-- | drivers/rtc/rtc-s3c.c | 60 |
1 files changed, 13 insertions, 47 deletions
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 77823d21d314..404651464d45 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 | ||
| 50 | static struct resource *s3c_rtc_mem; | ||
| 51 | |||
| 52 | static struct clk *rtc_clk; | 50 | static struct clk *rtc_clk; |
| 53 | static void __iomem *s3c_rtc_base; | 51 | static void __iomem *s3c_rtc_base; |
| 54 | static int s3c_rtc_alarmno = NO_IRQ; | 52 | static int s3c_rtc_alarmno = NO_IRQ; |
| @@ -186,7 +184,7 @@ static int s3c_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm) | |||
| 186 | rtc_tm->tm_year = readb(base + S3C2410_RTCYEAR); | 184 | rtc_tm->tm_year = readb(base + S3C2410_RTCYEAR); |
| 187 | rtc_tm->tm_sec = readb(base + S3C2410_RTCSEC); | 185 | rtc_tm->tm_sec = readb(base + S3C2410_RTCSEC); |
| 188 | 186 | ||
| 189 | /* the only way to work out wether the system was mid-update | 187 | /* the only way to work out whether the system was mid-update |
| 190 | * when we read it is to check the second counter, and if it | 188 | * when we read it is to check the second counter, and if it |
| 191 | * is zero, then we re-try the entire read | 189 | * is zero, then we re-try the entire read |
| 192 | */ | 190 | */ |
| @@ -423,25 +421,17 @@ static void s3c_rtc_enable(struct platform_device *pdev, int en) | |||
| 423 | clk_disable(rtc_clk); | 421 | clk_disable(rtc_clk); |
| 424 | } | 422 | } |
| 425 | 423 | ||
| 426 | static int __devexit s3c_rtc_remove(struct platform_device *dev) | 424 | static int 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 | ||
| @@ -461,7 +451,7 @@ static inline int s3c_rtc_get_driver_data(struct platform_device *pdev) | |||
| 461 | return platform_get_device_id(pdev)->driver_data; | 451 | return platform_get_device_id(pdev)->driver_data; |
| 462 | } | 452 | } |
| 463 | 453 | ||
| 464 | static int __devinit s3c_rtc_probe(struct platform_device *pdev) | 454 | static int s3c_rtc_probe(struct platform_device *pdev) |
| 465 | { | 455 | { |
| 466 | struct rtc_device *rtc; | 456 | struct rtc_device *rtc; |
| 467 | struct rtc_time rtc_tm; | 457 | struct rtc_time rtc_tm; |
| @@ -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 | }; |
| 697 | MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match); | 665 | MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match); |
| 698 | #else | ||
| 699 | #define s3c_rtc_dt_match NULL | ||
| 700 | #endif | 666 | #endif |
| 701 | 667 | ||
| 702 | static struct platform_device_id s3c_rtc_driver_ids[] = { | 668 | static struct platform_device_id s3c_rtc_driver_ids[] = { |
| @@ -720,14 +686,14 @@ MODULE_DEVICE_TABLE(platform, s3c_rtc_driver_ids); | |||
| 720 | 686 | ||
| 721 | static struct platform_driver s3c_rtc_driver = { | 687 | static struct platform_driver s3c_rtc_driver = { |
| 722 | .probe = s3c_rtc_probe, | 688 | .probe = s3c_rtc_probe, |
| 723 | .remove = __devexit_p(s3c_rtc_remove), | 689 | .remove = s3c_rtc_remove, |
| 724 | .suspend = s3c_rtc_suspend, | 690 | .suspend = s3c_rtc_suspend, |
| 725 | .resume = s3c_rtc_resume, | 691 | .resume = s3c_rtc_resume, |
| 726 | .id_table = s3c_rtc_driver_ids, | 692 | .id_table = s3c_rtc_driver_ids, |
| 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 | ||
