Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: cevt-ds1287: Migrate to new 'set-state' interface

Migrate cevt-ds1287 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.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: linux-mips@linux-mips.org
Cc: linaro-kernel@lists.linaro.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Patchwork: https://patchwork.linux-mips.org/patch/10603/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Viresh Kumar and committed by
Ralf Baechle
9f95618f 1edf907a

+24 -17
+24 -17
arch/mips/kernel/cevt-ds1287.c
··· 59 59 return -EINVAL; 60 60 } 61 61 62 - static void ds1287_set_mode(enum clock_event_mode mode, 63 - struct clock_event_device *evt) 62 + static int ds1287_shutdown(struct clock_event_device *evt) 64 63 { 65 64 u8 val; 66 65 67 66 spin_lock(&rtc_lock); 68 67 69 68 val = CMOS_READ(RTC_REG_B); 70 - 71 - switch (mode) { 72 - case CLOCK_EVT_MODE_PERIODIC: 73 - val |= RTC_PIE; 74 - break; 75 - default: 76 - val &= ~RTC_PIE; 77 - break; 78 - } 79 - 69 + val &= ~RTC_PIE; 80 70 CMOS_WRITE(val, RTC_REG_B); 81 71 82 72 spin_unlock(&rtc_lock); 73 + return 0; 74 + } 75 + 76 + static int ds1287_set_periodic(struct clock_event_device *evt) 77 + { 78 + u8 val; 79 + 80 + spin_lock(&rtc_lock); 81 + 82 + val = CMOS_READ(RTC_REG_B); 83 + val |= RTC_PIE; 84 + CMOS_WRITE(val, RTC_REG_B); 85 + 86 + spin_unlock(&rtc_lock); 87 + return 0; 83 88 } 84 89 85 90 static void ds1287_event_handler(struct clock_event_device *dev) ··· 92 87 } 93 88 94 89 static struct clock_event_device ds1287_clockevent = { 95 - .name = "ds1287", 96 - .features = CLOCK_EVT_FEAT_PERIODIC, 97 - .set_next_event = ds1287_set_next_event, 98 - .set_mode = ds1287_set_mode, 99 - .event_handler = ds1287_event_handler, 90 + .name = "ds1287", 91 + .features = CLOCK_EVT_FEAT_PERIODIC, 92 + .set_next_event = ds1287_set_next_event, 93 + .set_state_shutdown = ds1287_shutdown, 94 + .set_state_periodic = ds1287_set_periodic, 95 + .tick_resume = ds1287_shutdown, 96 + .event_handler = ds1287_event_handler, 100 97 }; 101 98 102 99 static irqreturn_t ds1287_interrupt(int irq, void *dev_id)