diff options
-rw-r--r-- | drivers/clocksource/sh_cmt.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 9f215e74751c..bc8d025ce861 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c | |||
@@ -785,10 +785,28 @@ static void sh_cmt_clock_event_resume(struct clock_event_device *ced) | |||
785 | pm_genpd_syscore_poweron(&ch->cmt->pdev->dev); | 785 | pm_genpd_syscore_poweron(&ch->cmt->pdev->dev); |
786 | } | 786 | } |
787 | 787 | ||
788 | static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, | 788 | static int sh_cmt_register_clockevent(struct sh_cmt_channel *ch, |
789 | const char *name) | 789 | const char *name) |
790 | { | 790 | { |
791 | struct clock_event_device *ced = &ch->ced; | 791 | struct clock_event_device *ced = &ch->ced; |
792 | int irq; | ||
793 | int ret; | ||
794 | |||
795 | irq = platform_get_irq(ch->cmt->pdev, ch->cmt->legacy ? 0 : ch->index); | ||
796 | if (irq < 0) { | ||
797 | dev_err(&ch->cmt->pdev->dev, "ch%u: failed to get irq\n", | ||
798 | ch->index); | ||
799 | return irq; | ||
800 | } | ||
801 | |||
802 | ret = request_irq(irq, sh_cmt_interrupt, | ||
803 | IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, | ||
804 | dev_name(&ch->cmt->pdev->dev), ch); | ||
805 | if (ret) { | ||
806 | dev_err(&ch->cmt->pdev->dev, "ch%u: failed to request irq %d\n", | ||
807 | ch->index, irq); | ||
808 | return ret; | ||
809 | } | ||
792 | 810 | ||
793 | ced->name = name; | 811 | ced->name = name; |
794 | ced->features = CLOCK_EVT_FEAT_PERIODIC; | 812 | ced->features = CLOCK_EVT_FEAT_PERIODIC; |
@@ -803,14 +821,20 @@ static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, | |||
803 | dev_info(&ch->cmt->pdev->dev, "ch%u: used for clock events\n", | 821 | dev_info(&ch->cmt->pdev->dev, "ch%u: used for clock events\n", |
804 | ch->index); | 822 | ch->index); |
805 | clockevents_register_device(ced); | 823 | clockevents_register_device(ced); |
824 | |||
825 | return 0; | ||
806 | } | 826 | } |
807 | 827 | ||
808 | static int sh_cmt_register(struct sh_cmt_channel *ch, const char *name, | 828 | static int sh_cmt_register(struct sh_cmt_channel *ch, const char *name, |
809 | bool clockevent, bool clocksource) | 829 | bool clockevent, bool clocksource) |
810 | { | 830 | { |
831 | int ret; | ||
832 | |||
811 | if (clockevent) { | 833 | if (clockevent) { |
812 | ch->cmt->has_clockevent = true; | 834 | ch->cmt->has_clockevent = true; |
813 | sh_cmt_register_clockevent(ch, name); | 835 | ret = sh_cmt_register_clockevent(ch, name); |
836 | if (ret < 0) | ||
837 | return ret; | ||
814 | } | 838 | } |
815 | 839 | ||
816 | if (clocksource) { | 840 | if (clocksource) { |
@@ -825,7 +849,6 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, | |||
825 | unsigned int hwidx, bool clockevent, | 849 | unsigned int hwidx, bool clockevent, |
826 | bool clocksource, struct sh_cmt_device *cmt) | 850 | bool clocksource, struct sh_cmt_device *cmt) |
827 | { | 851 | { |
828 | int irq; | ||
829 | int ret; | 852 | int ret; |
830 | 853 | ||
831 | /* Skip unused channels. */ | 854 | /* Skip unused channels. */ |
@@ -869,17 +892,6 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, | |||
869 | } | 892 | } |
870 | } | 893 | } |
871 | 894 | ||
872 | if (cmt->legacy) | ||
873 | irq = platform_get_irq(cmt->pdev, 0); | ||
874 | else | ||
875 | irq = platform_get_irq(cmt->pdev, ch->index); | ||
876 | |||
877 | if (irq < 0) { | ||
878 | dev_err(&cmt->pdev->dev, "ch%u: failed to get irq\n", | ||
879 | ch->index); | ||
880 | return irq; | ||
881 | } | ||
882 | |||
883 | if (cmt->info->width == (sizeof(ch->max_match_value) * 8)) | 895 | if (cmt->info->width == (sizeof(ch->max_match_value) * 8)) |
884 | ch->max_match_value = ~0; | 896 | ch->max_match_value = ~0; |
885 | else | 897 | else |
@@ -904,15 +916,6 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, | |||
904 | } | 916 | } |
905 | ch->cs_enabled = false; | 917 | ch->cs_enabled = false; |
906 | 918 | ||
907 | ret = request_irq(irq, sh_cmt_interrupt, | ||
908 | IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, | ||
909 | dev_name(&cmt->pdev->dev), ch); | ||
910 | if (ret) { | ||
911 | dev_err(&cmt->pdev->dev, "ch%u: failed to request irq %d\n", | ||
912 | ch->index, irq); | ||
913 | return ret; | ||
914 | } | ||
915 | |||
916 | return 0; | 919 | return 0; |
917 | } | 920 | } |
918 | 921 | ||