Skip to content

Commit 77cc982

Browse files
shawnguo2olofj
authored andcommitted
clocksource: use clockevents_config_and_register() where possible
The clockevent core is able to figure out the best mult and shift, calculate min_delta_ns and max_delta_ns, with the necessary info passed into clockevents_config_and_register(). Use this combined configure and register function where possible to make the codes less error prone and gain some positive diff stat. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Cc: Andres Salomon <dilinger@queued.net> Cc: Nicolas Ferre <nicolas.ferre@atmel.com> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Olof Johansson <olof@lixom.net>
1 parent 838a2ae commit 77cc982

File tree

3 files changed

+5
-24
lines changed

3 files changed

+5
-24
lines changed

drivers/clocksource/cs5535-clockevt.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ static struct clock_event_device cs5535_clockevent = {
100100
.set_mode = mfgpt_set_mode,
101101
.set_next_event = mfgpt_next_event,
102102
.rating = 250,
103-
.shift = 32
104103
};
105104

106105
static irqreturn_t mfgpt_tick(int irq, void *dev_id)
@@ -169,17 +168,11 @@ static int __init cs5535_mfgpt_init(void)
169168
cs5535_mfgpt_write(cs5535_event_clock, MFGPT_REG_SETUP, val);
170169

171170
/* Set up the clock event */
172-
cs5535_clockevent.mult = div_sc(MFGPT_HZ, NSEC_PER_SEC,
173-
cs5535_clockevent.shift);
174-
cs5535_clockevent.min_delta_ns = clockevent_delta2ns(0xF,
175-
&cs5535_clockevent);
176-
cs5535_clockevent.max_delta_ns = clockevent_delta2ns(0xFFFE,
177-
&cs5535_clockevent);
178-
179171
printk(KERN_INFO DRV_NAME
180172
": Registering MFGPT timer as a clock event, using IRQ %d\n",
181173
timer_irq);
182-
clockevents_register_device(&cs5535_clockevent);
174+
clockevents_config_and_register(&cs5535_clockevent, MFGPT_HZ,
175+
0xF, 0xFFFE);
183176

184177
return 0;
185178

drivers/clocksource/sunxi_timer.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ static int sunxi_clkevt_next_event(unsigned long evt,
7474

7575
static struct clock_event_device sunxi_clockevent = {
7676
.name = "sunxi_tick",
77-
.shift = 32,
7877
.rating = 300,
7978
.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
8079
.set_mode = sunxi_clkevt_mode,
@@ -154,16 +153,10 @@ static void __init sunxi_timer_init(void)
154153
val = readl(timer_base + TIMER_CTL_REG);
155154
writel(val | TIMER_CTL_ENABLE, timer_base + TIMER_CTL_REG);
156155

157-
sunxi_clockevent.mult = div_sc(rate / TIMER_SCAL,
158-
NSEC_PER_SEC,
159-
sunxi_clockevent.shift);
160-
sunxi_clockevent.max_delta_ns = clockevent_delta2ns(0xff,
161-
&sunxi_clockevent);
162-
sunxi_clockevent.min_delta_ns = clockevent_delta2ns(0x1,
163-
&sunxi_clockevent);
164156
sunxi_clockevent.cpumask = cpumask_of(0);
165157

166-
clockevents_register_device(&sunxi_clockevent);
158+
clockevents_config_and_register(&sunxi_clockevent, rate / TIMER_SCAL,
159+
0x1, 0xff);
167160
}
168161

169162
struct sys_timer sunxi_timer = {

drivers/clocksource/tcb_clksrc.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ static struct tc_clkevt_device clkevt = {
157157
.name = "tc_clkevt",
158158
.features = CLOCK_EVT_FEAT_PERIODIC
159159
| CLOCK_EVT_FEAT_ONESHOT,
160-
.shift = 32,
161160
/* Should be lower than at91rm9200's system timer */
162161
.rating = 125,
163162
.set_next_event = tc_next_event,
@@ -196,13 +195,9 @@ static void __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
196195

197196
timer_clock = clk32k_divisor_idx;
198197

199-
clkevt.clkevt.mult = div_sc(32768, NSEC_PER_SEC, clkevt.clkevt.shift);
200-
clkevt.clkevt.max_delta_ns
201-
= clockevent_delta2ns(0xffff, &clkevt.clkevt);
202-
clkevt.clkevt.min_delta_ns = clockevent_delta2ns(1, &clkevt.clkevt) + 1;
203198
clkevt.clkevt.cpumask = cpumask_of(0);
204199

205-
clockevents_register_device(&clkevt.clkevt);
200+
clockevents_config_and_register(&clkevt.clkevt, 32768, 1, 0xffff);
206201

207202
setup_irq(irq, &tc_irqaction);
208203
}

0 commit comments

Comments
 (0)