From df099a1998cda393d7f0db7c649affc475e21c73 Mon Sep 17 00:00:00 2001 From: Matthias Luescher Date: Thu, 17 Dec 2009 17:21:03 +0100 Subject: [PATCH] fix build for recent kernel versions (tested with 2.6.31) --- master/master.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/master/master.c b/master/master.c index 9e56e6fe..c6217167 100644 --- a/master/master.c +++ b/master/master.c @@ -1133,6 +1133,20 @@ static enum hrtimer_restart ec_master_nanosleep_wakeup(struct hrtimer *timer) return HRTIMER_NORESTART; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) +/* compatibility with new hrtimer interface */ +static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer) +{ + return timer->expires; +} + +static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time) +{ + timer->expires = time; +} +#endif + + void ec_master_nanosleep(const unsigned long nsecs) { struct hrtimer_sleeper t; @@ -1141,12 +1155,18 @@ void ec_master_nanosleep(const unsigned long nsecs) t.timer.function = ec_master_nanosleep_wakeup; t.task = current; #ifdef CONFIG_HIGH_RES_TIMERS +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 24) t.timer.cb_mode = HRTIMER_CB_IRQSAFE_NO_RESTART; +#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 26) + t.timer.cb_mode = HRTIMER_CB_IRQSAFE_NO_SOFTIRQ; +#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 28) + t.timer.cb_mode = HRTIMER_CB_IRQSAFE_UNLOCKED; #endif - t.timer.expires = ktime_set(0,nsecs); +#endif + hrtimer_set_expires(&t.timer, ktime_set(0,nsecs)); do { set_current_state(TASK_INTERRUPTIBLE); - hrtimer_start(&t.timer, t.timer.expires, mode); + hrtimer_start(&t.timer, hrtimer_get_expires(&t.timer), mode); if (likely(t.task)) schedule();