summaryrefslogtreecommitdiffstats
path: root/drivers/clocksource
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2017-03-11 12:42:29 -0500
committerDaniel Lezcano <daniel.lezcano@linaro.org>2017-04-07 10:23:03 -0400
commit0d9298ea37b5f590f3d10ccc2d8d34d26af3fa84 (patch)
tree3f6c890b6d0fde292f02fa58caf9fde538f2b184 /drivers/clocksource
parent5fc63f9577322d11019b6d357f73f5ce9031f263 (diff)
clocksource/drivers/orion: Read clock rate once
Rather than reading the clock rate three times, read it once - we are about to add a fourth usage. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'drivers/clocksource')
-rw-r--r--drivers/clocksource/time-orion.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/clocksource/time-orion.c b/drivers/clocksource/time-orion.c
index a28f496e97cf..c4818a5dc8e5 100644
--- a/drivers/clocksource/time-orion.c
+++ b/drivers/clocksource/time-orion.c
@@ -106,6 +106,7 @@ static struct irqaction orion_clkevt_irq = {
106 106
107static int __init orion_timer_init(struct device_node *np) 107static int __init orion_timer_init(struct device_node *np)
108{ 108{
109 unsigned long rate;
109 struct clk *clk; 110 struct clk *clk;
110 int irq, ret; 111 int irq, ret;
111 112
@@ -135,6 +136,8 @@ static int __init orion_timer_init(struct device_node *np)
135 return -EINVAL; 136 return -EINVAL;
136 } 137 }
137 138
139 rate = clk_get_rate(clk);
140
138 /* setup timer0 as free-running clocksource */ 141 /* setup timer0 as free-running clocksource */
139 writel(~0, timer_base + TIMER0_VAL); 142 writel(~0, timer_base + TIMER0_VAL);
140 writel(~0, timer_base + TIMER0_RELOAD); 143 writel(~0, timer_base + TIMER0_RELOAD);
@@ -142,15 +145,15 @@ static int __init orion_timer_init(struct device_node *np)
142 TIMER0_RELOAD_EN | TIMER0_EN, 145 TIMER0_RELOAD_EN | TIMER0_EN,
143 TIMER0_RELOAD_EN | TIMER0_EN); 146 TIMER0_RELOAD_EN | TIMER0_EN);
144 147
145 ret = clocksource_mmio_init(timer_base + TIMER0_VAL, "orion_clocksource", 148 ret = clocksource_mmio_init(timer_base + TIMER0_VAL,
146 clk_get_rate(clk), 300, 32, 149 "orion_clocksource", rate, 300, 32,
147 clocksource_mmio_readl_down); 150 clocksource_mmio_readl_down);
148 if (ret) { 151 if (ret) {
149 pr_err("Failed to initialize mmio timer"); 152 pr_err("Failed to initialize mmio timer");
150 return ret; 153 return ret;
151 } 154 }
152 155
153 sched_clock_register(orion_read_sched_clock, 32, clk_get_rate(clk)); 156 sched_clock_register(orion_read_sched_clock, 32, rate);
154 157
155 /* setup timer1 as clockevent timer */ 158 /* setup timer1 as clockevent timer */
156 ret = setup_irq(irq, &orion_clkevt_irq); 159 ret = setup_irq(irq, &orion_clkevt_irq);
@@ -162,7 +165,7 @@ static int __init orion_timer_init(struct device_node *np)
162 ticks_per_jiffy = (clk_get_rate(clk) + HZ/2) / HZ; 165 ticks_per_jiffy = (clk_get_rate(clk) + HZ/2) / HZ;
163 orion_clkevt.cpumask = cpumask_of(0); 166 orion_clkevt.cpumask = cpumask_of(0);
164 orion_clkevt.irq = irq; 167 orion_clkevt.irq = irq;
165 clockevents_config_and_register(&orion_clkevt, clk_get_rate(clk), 168 clockevents_config_and_register(&orion_clkevt, rate,
166 ORION_ONESHOT_MIN, ORION_ONESHOT_MAX); 169 ORION_ONESHOT_MIN, ORION_ONESHOT_MAX);
167 170
168 return 0; 171 return 0;