master/master.c
changeset 1603 8e528f806dc5
parent 1600 e36c92cf58a9
child 1605 1a588303083a
equal deleted inserted replaced
1601:a784812c787f 1603:8e528f806dc5
  1131 		wake_up_process(task);
  1131 		wake_up_process(task);
  1132 
  1132 
  1133 	return HRTIMER_NORESTART;
  1133 	return HRTIMER_NORESTART;
  1134 }
  1134 }
  1135 
  1135 
       
  1136 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
       
  1137 /* compatibility with new hrtimer interface */
       
  1138 static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer)
       
  1139 {
       
  1140 	return timer->expires;
       
  1141 }
       
  1142 
       
  1143 static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time)
       
  1144 {
       
  1145 	timer->expires = time;
       
  1146 }
       
  1147 #endif
       
  1148 
       
  1149 
  1136 void ec_master_nanosleep(const unsigned long nsecs)
  1150 void ec_master_nanosleep(const unsigned long nsecs)
  1137 {
  1151 {
  1138 	struct hrtimer_sleeper t;
  1152 	struct hrtimer_sleeper t;
  1139 	enum hrtimer_mode mode = HRTIMER_MODE_REL;
  1153 	enum hrtimer_mode mode = HRTIMER_MODE_REL;
  1140 	hrtimer_init(&t.timer, CLOCK_MONOTONIC,mode);
  1154 	hrtimer_init(&t.timer, CLOCK_MONOTONIC,mode);
  1141 	t.timer.function = ec_master_nanosleep_wakeup;
  1155 	t.timer.function = ec_master_nanosleep_wakeup;
  1142 	t.task = current;
  1156 	t.task = current;
  1143 #ifdef CONFIG_HIGH_RES_TIMERS
  1157 #ifdef CONFIG_HIGH_RES_TIMERS
       
  1158 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 24)
  1144 	t.timer.cb_mode = HRTIMER_CB_IRQSAFE_NO_RESTART;
  1159 	t.timer.cb_mode = HRTIMER_CB_IRQSAFE_NO_RESTART;
  1145 #endif
  1160 #elif LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 26)
  1146 	t.timer.expires = ktime_set(0,nsecs);
  1161 	t.timer.cb_mode = HRTIMER_CB_IRQSAFE_NO_SOFTIRQ;
       
  1162 #elif LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 28)
       
  1163 	t.timer.cb_mode = HRTIMER_CB_IRQSAFE_UNLOCKED;
       
  1164 #endif
       
  1165 #endif
       
  1166 	hrtimer_set_expires(&t.timer, ktime_set(0,nsecs));
  1147 	do {
  1167 	do {
  1148 		set_current_state(TASK_INTERRUPTIBLE);
  1168 		set_current_state(TASK_INTERRUPTIBLE);
  1149 		hrtimer_start(&t.timer, t.timer.expires, mode);
  1169 		hrtimer_start(&t.timer, hrtimer_get_expires(&t.timer), mode);
  1150 
  1170 
  1151 		if (likely(t.task))
  1171 		if (likely(t.task))
  1152 			schedule();
  1172 			schedule();
  1153 
  1173 
  1154 		hrtimer_cancel(&t.timer);
  1174 		hrtimer_cancel(&t.timer);