clocksource: use clockevents_config_and_register() where possible
authorShawn Guo <shawn.guo@linaro.org>
Sat, 12 Jan 2013 11:50:06 +0000 (11:50 +0000)
committerOlof Johansson <olof@lixom.net>
Mon, 14 Jan 2013 18:12:42 +0000 (10:12 -0800)
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>
drivers/clocksource/cs5535-clockevt.c
drivers/clocksource/sunxi_timer.c
drivers/clocksource/tcb_clksrc.c

index d9279385304d8b86fff47d58f3b623b0c804a046..ea210482dd2099af6ce35e31bd234fcc18a4d970 100644 (file)
@@ -100,7 +100,6 @@ static struct clock_event_device cs5535_clockevent = {
        .set_mode = mfgpt_set_mode,
        .set_next_event = mfgpt_next_event,
        .rating = 250,
-       .shift = 32
 };
 
 static irqreturn_t mfgpt_tick(int irq, void *dev_id)
@@ -169,17 +168,11 @@ static int __init cs5535_mfgpt_init(void)
        cs5535_mfgpt_write(cs5535_event_clock, MFGPT_REG_SETUP, val);
 
        /* Set up the clock event */
-       cs5535_clockevent.mult = div_sc(MFGPT_HZ, NSEC_PER_SEC,
-                       cs5535_clockevent.shift);
-       cs5535_clockevent.min_delta_ns = clockevent_delta2ns(0xF,
-                       &cs5535_clockevent);
-       cs5535_clockevent.max_delta_ns = clockevent_delta2ns(0xFFFE,
-                       &cs5535_clockevent);
-
        printk(KERN_INFO DRV_NAME
                ": Registering MFGPT timer as a clock event, using IRQ %d\n",
                timer_irq);
-       clockevents_register_device(&cs5535_clockevent);
+       clockevents_config_and_register(&cs5535_clockevent, MFGPT_HZ,
+                                       0xF, 0xFFFE);
 
        return 0;
 
index 3cd1bd3d7aee7fd0f6c77143bfb11b8d1100e59e..f9118664e440c0421b4666bf5f010ca4736c12a6 100644 (file)
@@ -74,7 +74,6 @@ static int sunxi_clkevt_next_event(unsigned long evt,
 
 static struct clock_event_device sunxi_clockevent = {
        .name = "sunxi_tick",
-       .shift = 32,
        .rating = 300,
        .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
        .set_mode = sunxi_clkevt_mode,
@@ -154,16 +153,10 @@ static void __init sunxi_timer_init(void)
        val = readl(timer_base + TIMER_CTL_REG);
        writel(val | TIMER_CTL_ENABLE, timer_base + TIMER_CTL_REG);
 
-       sunxi_clockevent.mult = div_sc(rate / TIMER_SCAL,
-                               NSEC_PER_SEC,
-                               sunxi_clockevent.shift);
-       sunxi_clockevent.max_delta_ns = clockevent_delta2ns(0xff,
-                                                           &sunxi_clockevent);
-       sunxi_clockevent.min_delta_ns = clockevent_delta2ns(0x1,
-                                                           &sunxi_clockevent);
        sunxi_clockevent.cpumask = cpumask_of(0);
 
-       clockevents_register_device(&sunxi_clockevent);
+       clockevents_config_and_register(&sunxi_clockevent, rate / TIMER_SCAL,
+                                       0x1, 0xff);
 }
 
 struct sys_timer sunxi_timer = {
index 32cb929b8eb62ae387fc20b122c5d5a21da3f10b..8a6187225dd0e7faa9b25c14147be31f3b7a9539 100644 (file)
@@ -157,7 +157,6 @@ static struct tc_clkevt_device clkevt = {
                .name           = "tc_clkevt",
                .features       = CLOCK_EVT_FEAT_PERIODIC
                                        | CLOCK_EVT_FEAT_ONESHOT,
-               .shift          = 32,
                /* Should be lower than at91rm9200's system timer */
                .rating         = 125,
                .set_next_event = tc_next_event,
@@ -196,13 +195,9 @@ static void __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
 
        timer_clock = clk32k_divisor_idx;
 
-       clkevt.clkevt.mult = div_sc(32768, NSEC_PER_SEC, clkevt.clkevt.shift);
-       clkevt.clkevt.max_delta_ns
-               = clockevent_delta2ns(0xffff, &clkevt.clkevt);
-       clkevt.clkevt.min_delta_ns = clockevent_delta2ns(1, &clkevt.clkevt) + 1;
        clkevt.clkevt.cpumask = cpumask_of(0);
 
-       clockevents_register_device(&clkevt.clkevt);
+       clockevents_config_and_register(&clkevt.clkevt, 32768, 1, 0xffff);
 
        setup_irq(irq, &tc_irqaction);
 }
This page took 0.026308 seconds and 5 git commands to generate.