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