aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/posix-timers.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/posix-timers.c')
-rw-r--r--kernel/posix-timers.c37
1 files changed, 9 insertions, 28 deletions
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index 3b606d361b52..28e72fd0029f 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -194,9 +194,7 @@ static inline int common_clock_set(const clockid_t which_clock,
194 194
195static int common_timer_create(struct k_itimer *new_timer) 195static int common_timer_create(struct k_itimer *new_timer)
196{ 196{
197 hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock); 197 hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock, 0);
198 new_timer->it.real.timer.data = new_timer;
199 new_timer->it.real.timer.function = posix_timer_fn;
200 return 0; 198 return 0;
201} 199}
202 200
@@ -693,6 +691,7 @@ common_timer_set(struct k_itimer *timr, int flags,
693 struct itimerspec *new_setting, struct itimerspec *old_setting) 691 struct itimerspec *new_setting, struct itimerspec *old_setting)
694{ 692{
695 struct hrtimer *timer = &timr->it.real.timer; 693 struct hrtimer *timer = &timr->it.real.timer;
694 enum hrtimer_mode mode;
696 695
697 if (old_setting) 696 if (old_setting)
698 common_timer_get(timr, old_setting); 697 common_timer_get(timr, old_setting);
@@ -714,14 +713,10 @@ common_timer_set(struct k_itimer *timr, int flags,
714 if (!new_setting->it_value.tv_sec && !new_setting->it_value.tv_nsec) 713 if (!new_setting->it_value.tv_sec && !new_setting->it_value.tv_nsec)
715 return 0; 714 return 0;
716 715
717 /* Posix madness. Only absolute CLOCK_REALTIME timers 716 mode = flags & TIMER_ABSTIME ? HRTIMER_ABS : HRTIMER_REL;
718 * are affected by clock sets. So we must reiniatilize 717 hrtimer_init(&timr->it.real.timer, timr->it_clock, mode);
719 * the timer. 718 timr->it.real.timer.data = timr;
720 */ 719 timr->it.real.timer.function = posix_timer_fn;
721 if (timr->it_clock == CLOCK_REALTIME && (flags & TIMER_ABSTIME))
722 hrtimer_rebase(timer, CLOCK_REALTIME);
723 else
724 hrtimer_rebase(timer, CLOCK_MONOTONIC);
725 720
726 timer->expires = timespec_to_ktime(new_setting->it_value); 721 timer->expires = timespec_to_ktime(new_setting->it_value);
727 722
@@ -732,8 +727,7 @@ common_timer_set(struct k_itimer *timr, int flags,
732 if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) 727 if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE))
733 return 0; 728 return 0;
734 729
735 hrtimer_start(timer, timer->expires, (flags & TIMER_ABSTIME) ? 730 hrtimer_start(timer, timer->expires, mode);
736 HRTIMER_ABS : HRTIMER_REL);
737 return 0; 731 return 0;
738} 732}
739 733
@@ -948,21 +942,8 @@ sys_clock_getres(const clockid_t which_clock, struct timespec __user *tp)
948static int common_nsleep(const clockid_t which_clock, int flags, 942static int common_nsleep(const clockid_t which_clock, int flags,
949 struct timespec *tsave, struct timespec __user *rmtp) 943 struct timespec *tsave, struct timespec __user *rmtp)
950{ 944{
951 int mode = flags & TIMER_ABSTIME ? HRTIMER_ABS : HRTIMER_REL; 945 return hrtimer_nanosleep(tsave, rmtp, flags & TIMER_ABSTIME ?
952 int clockid = which_clock; 946 HRTIMER_ABS : HRTIMER_REL, which_clock);
953
954 switch (which_clock) {
955 case CLOCK_REALTIME:
956 /* Posix madness. Only absolute timers on clock realtime
957 are affected by clock set. */
958 if (mode != HRTIMER_ABS)
959 clockid = CLOCK_MONOTONIC;
960 case CLOCK_MONOTONIC:
961 break;
962 default:
963 return -EINVAL;
964 }
965 return hrtimer_nanosleep(tsave, rmtp, mode, clockid);
966} 947}
967 948
968asmlinkage long 949asmlinkage long