]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ARM/dc21285-timer: Migrate to new 'set-state' interface
authorViresh Kumar <viresh.kumar@linaro.org>
Fri, 27 Feb 2015 08:09:52 +0000 (13:39 +0530)
committerViresh Kumar <viresh.kumar@linaro.org>
Fri, 17 Jul 2015 02:52:56 +0000 (08:22 +0530)
Migrate footbridge driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
arch/arm/mach-footbridge/dc21285-timer.c

index bf7aa7d298e7da11324087ef60b06928c00479c2..810edc78c8172a7fc24f7121418cae34d67f73a5 100644 (file)
@@ -57,34 +57,32 @@ static int ckevt_dc21285_set_next_event(unsigned long delta,
        return 0;
 }
 
-static void ckevt_dc21285_set_mode(enum clock_event_mode mode,
-       struct clock_event_device *c)
+static int ckevt_dc21285_shutdown(struct clock_event_device *c)
 {
-       switch (mode) {
-       case CLOCK_EVT_MODE_RESUME:
-       case CLOCK_EVT_MODE_PERIODIC:
-               *CSR_TIMER1_CLR = 0;
-               *CSR_TIMER1_LOAD = (mem_fclk_21285 + 8 * HZ) / (16 * HZ);
-               *CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD |
-                                  TIMER_CNTL_DIV16;
-               break;
-
-       case CLOCK_EVT_MODE_ONESHOT:
-       case CLOCK_EVT_MODE_UNUSED:
-       case CLOCK_EVT_MODE_SHUTDOWN:
-               *CSR_TIMER1_CNTL = 0;
-               break;
-       }
+       *CSR_TIMER1_CNTL = 0;
+       return 0;
+}
+
+static int ckevt_dc21285_set_periodic(struct clock_event_device *c)
+{
+       *CSR_TIMER1_CLR = 0;
+       *CSR_TIMER1_LOAD = (mem_fclk_21285 + 8 * HZ) / (16 * HZ);
+       *CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD |
+                          TIMER_CNTL_DIV16;
+       return 0;
 }
 
 static struct clock_event_device ckevt_dc21285 = {
-       .name           = "dc21285_timer1",
-       .features       = CLOCK_EVT_FEAT_PERIODIC |
-                         CLOCK_EVT_FEAT_ONESHOT,
-       .rating         = 200,
-       .irq            = IRQ_TIMER1,
-       .set_next_event = ckevt_dc21285_set_next_event,
-       .set_mode       = ckevt_dc21285_set_mode,
+       .name                   = "dc21285_timer1",
+       .features               = CLOCK_EVT_FEAT_PERIODIC |
+                                 CLOCK_EVT_FEAT_ONESHOT,
+       .rating                 = 200,
+       .irq                    = IRQ_TIMER1,
+       .set_next_event         = ckevt_dc21285_set_next_event,
+       .set_state_shutdown     = ckevt_dc21285_shutdown,
+       .set_state_periodic     = ckevt_dc21285_set_periodic,
+       .set_state_oneshot      = ckevt_dc21285_shutdown,
+       .tick_resume            = ckevt_dc21285_set_periodic,
 };
 
 static irqreturn_t timer1_interrupt(int irq, void *dev_id)
@@ -94,7 +92,7 @@ static irqreturn_t timer1_interrupt(int irq, void *dev_id)
        *CSR_TIMER1_CLR = 0;
 
        /* Stop the timer if in one-shot mode */
-       if (ce->mode == CLOCK_EVT_MODE_ONESHOT)
+       if (clockevent_state_oneshot(ce))
                *CSR_TIMER1_CNTL = 0;
 
        ce->event_handler(ce);