aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/posix-timers.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2011-02-01 08:51:50 -0500
committerThomas Gleixner <tglx@linutronix.de>2011-02-02 09:28:14 -0500
commit42285777631aa0654fbb6442057b3e176445c6c5 (patch)
tree01938e8e6cc8fe11879fffcb036eb6859f117628 /kernel/posix-timers.c
parent26f9a4796af330173d790c8d2b5e2efcc489e755 (diff)
posix-timers: Convert clock_gettime() to clockid_to_kclock()
Use the new kclock decoding mechanism and rename the misnomed common_clock_get() to posix_clock_realtime_get(). 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: <20110201134418.611097203@linutronix.de>
Diffstat (limited to 'kernel/posix-timers.c')
-rw-r--r--kernel/posix-timers.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index 49f358c37708..d9e5edfe8a1b 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -190,15 +190,6 @@ static inline int common_clock_getres(const clockid_t which_clock,
190 return 0; 190 return 0;
191} 191}
192 192
193/*
194 * Get real time for posix timers
195 */
196static int common_clock_get(clockid_t which_clock, struct timespec *tp)
197{
198 ktime_get_real_ts(tp);
199 return 0;
200}
201
202static int common_timer_create(struct k_itimer *new_timer) 193static int common_timer_create(struct k_itimer *new_timer)
203{ 194{
204 hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock, 0); 195 hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock, 0);
@@ -226,6 +217,13 @@ static inline int invalid_clockid(const clockid_t which_clock)
226 return 1; 217 return 1;
227} 218}
228 219
220/* Get clock_realtime */
221static int posix_clock_realtime_get(clockid_t which_clock, struct timespec *tp)
222{
223 ktime_get_real_ts(tp);
224 return 0;
225}
226
229/* Set clock_realtime */ 227/* Set clock_realtime */
230static int posix_clock_realtime_set(const clockid_t which_clock, 228static int posix_clock_realtime_set(const clockid_t which_clock,
231 const struct timespec *tp) 229 const struct timespec *tp)
@@ -277,6 +275,7 @@ static __init int init_posix_timers(void)
277{ 275{
278 struct k_clock clock_realtime = { 276 struct k_clock clock_realtime = {
279 .clock_getres = hrtimer_get_res, 277 .clock_getres = hrtimer_get_res,
278 .clock_get = posix_clock_realtime_get,
280 .clock_set = posix_clock_realtime_set, 279 .clock_set = posix_clock_realtime_set,
281 .nsleep = common_nsleep, 280 .nsleep = common_nsleep,
282 .nsleep_restart = hrtimer_nanosleep_restart, 281 .nsleep_restart = hrtimer_nanosleep_restart,
@@ -956,18 +955,21 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
956SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock, 955SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
957 struct timespec __user *,tp) 956 struct timespec __user *,tp)
958{ 957{
958 struct k_clock *kc = clockid_to_kclock(which_clock);
959 struct timespec kernel_tp; 959 struct timespec kernel_tp;
960 int error; 960 int error;
961 961
962 if (invalid_clockid(which_clock)) 962 if (!kc)
963 return -EINVAL; 963 return -EINVAL;
964 error = CLOCK_DISPATCH(which_clock, clock_get, 964 if (!kc->clock_get)
965 (which_clock, &kernel_tp)); 965 return -EOPNOTSUPP;
966
967 error = kc->clock_get(which_clock, &kernel_tp);
968
966 if (!error && copy_to_user(tp, &kernel_tp, sizeof (kernel_tp))) 969 if (!error && copy_to_user(tp, &kernel_tp, sizeof (kernel_tp)))
967 error = -EFAULT; 970 error = -EFAULT;
968 971
969 return error; 972 return error;
970
971} 973}
972 974
973SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, 975SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,