diff options
author | Tushar Behera <tushar.behera@linaro.org> | 2012-12-17 19:02:48 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-17 20:15:21 -0500 |
commit | 1b99732932e1e398ec84baf6024afa23f5388716 (patch) | |
tree | 73e73ea634f1527e1c5165e474cf02d628dca191 /drivers/rtc/rtc-s3c.c | |
parent | 076c7265488cc4016c6502f3f9d8dbf1e97fd147 (diff) |
drivers/rtc/rtc-s3c.c: convert to use devm_* API
rtc-s3c driver is modified to use devm_request_and_ioremap() (combining
request_mem_region and ioremap), devm_clk_get() and devm_request_irq()
APIs. Since this removes the necessity of freeing the related resources
the return path is also simplified.
Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-s3c.c')
-rw-r--r-- | drivers/rtc/rtc-s3c.c | 45 |
1 files changed, 8 insertions, 37 deletions
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index d9da51193bc3..e33df1bfe27e 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; |
@@ -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,27 +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 | return -ENOENT; | ||
505 | } | ||
506 | |||
507 | s3c_rtc_base = ioremap(res->start, resource_size(res)); | ||
508 | if (s3c_rtc_base == NULL) { | 490 | if (s3c_rtc_base == NULL) { |
509 | dev_err(&pdev->dev, "failed ioremap()\n"); | 491 | dev_err(&pdev->dev, "failed to ioremap memory region\n"); |
510 | ret = -EINVAL; | 492 | return -EINVAL; |
511 | goto err_nomap; | ||
512 | } | 493 | } |
513 | 494 | ||
514 | rtc_clk = clk_get(&pdev->dev, "rtc"); | 495 | rtc_clk = devm_clk_get(&pdev->dev, "rtc"); |
515 | if (IS_ERR(rtc_clk)) { | 496 | if (IS_ERR(rtc_clk)) { |
516 | dev_err(&pdev->dev, "failed to find rtc clock source\n"); | 497 | dev_err(&pdev->dev, "failed to find rtc clock source\n"); |
517 | ret = PTR_ERR(rtc_clk); | 498 | ret = PTR_ERR(rtc_clk); |
518 | rtc_clk = NULL; | 499 | rtc_clk = NULL; |
519 | goto err_clk; | 500 | return ret; |
520 | } | 501 | } |
521 | 502 | ||
522 | clk_enable(rtc_clk); | 503 | clk_enable(rtc_clk); |
@@ -575,28 +556,24 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) | |||
575 | 556 | ||
576 | s3c_rtc_setfreq(&pdev->dev, 1); | 557 | s3c_rtc_setfreq(&pdev->dev, 1); |
577 | 558 | ||
578 | ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq, | 559 | ret = devm_request_irq(&pdev->dev, s3c_rtc_alarmno, s3c_rtc_alarmirq, |
579 | 0, "s3c2410-rtc alarm", rtc); | 560 | 0, "s3c2410-rtc alarm", rtc); |
580 | if (ret) { | 561 | if (ret) { |
581 | 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); |
582 | goto err_alarm_irq; | 563 | goto err_alarm_irq; |
583 | } | 564 | } |
584 | 565 | ||
585 | ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq, | 566 | ret = devm_request_irq(&pdev->dev, s3c_rtc_tickno, s3c_rtc_tickirq, |
586 | 0, "s3c2410-rtc tick", rtc); | 567 | 0, "s3c2410-rtc tick", rtc); |
587 | if (ret) { | 568 | if (ret) { |
588 | 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); |
589 | free_irq(s3c_rtc_alarmno, rtc); | 570 | goto err_alarm_irq; |
590 | goto err_tick_irq; | ||
591 | } | 571 | } |
592 | 572 | ||
593 | clk_disable(rtc_clk); | 573 | clk_disable(rtc_clk); |
594 | 574 | ||
595 | return 0; | 575 | return 0; |
596 | 576 | ||
597 | err_tick_irq: | ||
598 | free_irq(s3c_rtc_alarmno, rtc); | ||
599 | |||
600 | err_alarm_irq: | 577 | err_alarm_irq: |
601 | platform_set_drvdata(pdev, NULL); | 578 | platform_set_drvdata(pdev, NULL); |
602 | rtc_device_unregister(rtc); | 579 | rtc_device_unregister(rtc); |
@@ -604,13 +581,7 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) | |||
604 | err_nortc: | 581 | err_nortc: |
605 | s3c_rtc_enable(pdev, 0); | 582 | s3c_rtc_enable(pdev, 0); |
606 | clk_disable(rtc_clk); | 583 | clk_disable(rtc_clk); |
607 | clk_put(rtc_clk); | ||
608 | |||
609 | err_clk: | ||
610 | iounmap(s3c_rtc_base); | ||
611 | 584 | ||
612 | err_nomap: | ||
613 | release_resource(s3c_rtc_mem); | ||
614 | return ret; | 585 | return ret; |
615 | } | 586 | } |
616 | 587 | ||