diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2011-02-01 08:52:04 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2011-02-02 09:28:16 -0500 |
commit | a7319fa253a549c4c6528fb550ae6e72a9c83811 (patch) | |
tree | adc91fc50100e768323ed04d964c4221a6c36db4 /kernel/posix-timers.c | |
parent | 27722df16ef143017db55ac7baac1703a68017ff (diff) |
posix-timers: Convert timer_gettime() to clockid_to_kclock()
Set the common function for CLOCK_MONOTONIC and CLOCK_REALTIME kclocks
and use the new decoding function.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <johnstul@us.ibm.com>
Tested-by: Richard Cochran <richard.cochran@omicron.at>
LKML-Reference: <20110201134419.101243181@linutronix.de>
Diffstat (limited to 'kernel/posix-timers.c')
-rw-r--r-- | kernel/posix-timers.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index a4dbfe71c5a5..c1e2636f9e45 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c | |||
@@ -253,6 +253,7 @@ static __init int init_posix_timers(void) | |||
253 | .nsleep_restart = hrtimer_nanosleep_restart, | 253 | .nsleep_restart = hrtimer_nanosleep_restart, |
254 | .timer_create = common_timer_create, | 254 | .timer_create = common_timer_create, |
255 | .timer_set = common_timer_set, | 255 | .timer_set = common_timer_set, |
256 | .timer_get = common_timer_get, | ||
256 | }; | 257 | }; |
257 | struct k_clock clock_monotonic = { | 258 | struct k_clock clock_monotonic = { |
258 | .clock_getres = hrtimer_get_res, | 259 | .clock_getres = hrtimer_get_res, |
@@ -261,6 +262,7 @@ static __init int init_posix_timers(void) | |||
261 | .nsleep_restart = hrtimer_nanosleep_restart, | 262 | .nsleep_restart = hrtimer_nanosleep_restart, |
262 | .timer_create = common_timer_create, | 263 | .timer_create = common_timer_create, |
263 | .timer_set = common_timer_set, | 264 | .timer_set = common_timer_set, |
265 | .timer_get = common_timer_get, | ||
264 | }; | 266 | }; |
265 | struct k_clock clock_monotonic_raw = { | 267 | struct k_clock clock_monotonic_raw = { |
266 | .clock_getres = hrtimer_get_res, | 268 | .clock_getres = hrtimer_get_res, |
@@ -712,22 +714,28 @@ common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) | |||
712 | SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id, | 714 | SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id, |
713 | struct itimerspec __user *, setting) | 715 | struct itimerspec __user *, setting) |
714 | { | 716 | { |
715 | struct k_itimer *timr; | ||
716 | struct itimerspec cur_setting; | 717 | struct itimerspec cur_setting; |
718 | struct k_itimer *timr; | ||
719 | struct k_clock *kc; | ||
717 | unsigned long flags; | 720 | unsigned long flags; |
721 | int ret = 0; | ||
718 | 722 | ||
719 | timr = lock_timer(timer_id, &flags); | 723 | timr = lock_timer(timer_id, &flags); |
720 | if (!timr) | 724 | if (!timr) |
721 | return -EINVAL; | 725 | return -EINVAL; |
722 | 726 | ||
723 | CLOCK_DISPATCH(timr->it_clock, timer_get, (timr, &cur_setting)); | 727 | kc = clockid_to_kclock(timr->it_clock); |
728 | if (WARN_ON_ONCE(!kc || !kc->timer_get)) | ||
729 | ret = -EINVAL; | ||
730 | else | ||
731 | kc->timer_get(timr, &cur_setting); | ||
724 | 732 | ||
725 | unlock_timer(timr, flags); | 733 | unlock_timer(timr, flags); |
726 | 734 | ||
727 | if (copy_to_user(setting, &cur_setting, sizeof (cur_setting))) | 735 | if (!ret && copy_to_user(setting, &cur_setting, sizeof (cur_setting))) |
728 | return -EFAULT; | 736 | return -EFAULT; |
729 | 737 | ||
730 | return 0; | 738 | return ret; |
731 | } | 739 | } |
732 | 740 | ||
733 | /* | 741 | /* |