提交 a7319fa2 编写于 作者: T Thomas Gleixner

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: NThomas Gleixner <tglx@linutronix.de>
Acked-by: NJohn Stultz <johnstul@us.ibm.com>
Tested-by: NRichard Cochran <richard.cochran@omicron.at>
LKML-Reference: <20110201134419.101243181@linutronix.de>
上级 27722df1
...@@ -253,6 +253,7 @@ static __init int init_posix_timers(void) ...@@ -253,6 +253,7 @@ static __init int init_posix_timers(void)
.nsleep_restart = hrtimer_nanosleep_restart, .nsleep_restart = hrtimer_nanosleep_restart,
.timer_create = common_timer_create, .timer_create = common_timer_create,
.timer_set = common_timer_set, .timer_set = common_timer_set,
.timer_get = common_timer_get,
}; };
struct k_clock clock_monotonic = { struct k_clock clock_monotonic = {
.clock_getres = hrtimer_get_res, .clock_getres = hrtimer_get_res,
...@@ -261,6 +262,7 @@ static __init int init_posix_timers(void) ...@@ -261,6 +262,7 @@ static __init int init_posix_timers(void)
.nsleep_restart = hrtimer_nanosleep_restart, .nsleep_restart = hrtimer_nanosleep_restart,
.timer_create = common_timer_create, .timer_create = common_timer_create,
.timer_set = common_timer_set, .timer_set = common_timer_set,
.timer_get = common_timer_get,
}; };
struct k_clock clock_monotonic_raw = { struct k_clock clock_monotonic_raw = {
.clock_getres = hrtimer_get_res, .clock_getres = hrtimer_get_res,
...@@ -712,22 +714,28 @@ common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) ...@@ -712,22 +714,28 @@ common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting)
SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id, SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
struct itimerspec __user *, setting) struct itimerspec __user *, setting)
{ {
struct k_itimer *timr;
struct itimerspec cur_setting; struct itimerspec cur_setting;
struct k_itimer *timr;
struct k_clock *kc;
unsigned long flags; unsigned long flags;
int ret = 0;
timr = lock_timer(timer_id, &flags); timr = lock_timer(timer_id, &flags);
if (!timr) if (!timr)
return -EINVAL; return -EINVAL;
CLOCK_DISPATCH(timr->it_clock, timer_get, (timr, &cur_setting)); kc = clockid_to_kclock(timr->it_clock);
if (WARN_ON_ONCE(!kc || !kc->timer_get))
ret = -EINVAL;
else
kc->timer_get(timr, &cur_setting);
unlock_timer(timr, flags); unlock_timer(timr, flags);
if (copy_to_user(setting, &cur_setting, sizeof (cur_setting))) if (!ret && copy_to_user(setting, &cur_setting, sizeof (cur_setting)))
return -EFAULT; return -EFAULT;
return 0; return ret;
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册