mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-24 17:23:25 -05:00
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>
This commit is contained in:
parent
26f9a4796a
commit
4228577763
1 changed files with 15 additions and 13 deletions
|
@ -190,15 +190,6 @@ static inline int common_clock_getres(const clockid_t which_clock,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Get real time for posix timers
|
|
||||||
*/
|
|
||||||
static int common_clock_get(clockid_t which_clock, struct timespec *tp)
|
|
||||||
{
|
|
||||||
ktime_get_real_ts(tp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int common_timer_create(struct k_itimer *new_timer)
|
static int common_timer_create(struct k_itimer *new_timer)
|
||||||
{
|
{
|
||||||
hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock, 0);
|
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)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get clock_realtime */
|
||||||
|
static int posix_clock_realtime_get(clockid_t which_clock, struct timespec *tp)
|
||||||
|
{
|
||||||
|
ktime_get_real_ts(tp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set clock_realtime */
|
/* Set clock_realtime */
|
||||||
static int posix_clock_realtime_set(const clockid_t which_clock,
|
static int posix_clock_realtime_set(const clockid_t which_clock,
|
||||||
const struct timespec *tp)
|
const struct timespec *tp)
|
||||||
|
@ -277,6 +275,7 @@ static __init int init_posix_timers(void)
|
||||||
{
|
{
|
||||||
struct k_clock clock_realtime = {
|
struct k_clock clock_realtime = {
|
||||||
.clock_getres = hrtimer_get_res,
|
.clock_getres = hrtimer_get_res,
|
||||||
|
.clock_get = posix_clock_realtime_get,
|
||||||
.clock_set = posix_clock_realtime_set,
|
.clock_set = posix_clock_realtime_set,
|
||||||
.nsleep = common_nsleep,
|
.nsleep = common_nsleep,
|
||||||
.nsleep_restart = hrtimer_nanosleep_restart,
|
.nsleep_restart = hrtimer_nanosleep_restart,
|
||||||
|
@ -956,18 +955,21 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
|
||||||
SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
|
SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
|
||||||
struct timespec __user *,tp)
|
struct timespec __user *,tp)
|
||||||
{
|
{
|
||||||
|
struct k_clock *kc = clockid_to_kclock(which_clock);
|
||||||
struct timespec kernel_tp;
|
struct timespec kernel_tp;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (invalid_clockid(which_clock))
|
if (!kc)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
error = CLOCK_DISPATCH(which_clock, clock_get,
|
if (!kc->clock_get)
|
||||||
(which_clock, &kernel_tp));
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
|
error = kc->clock_get(which_clock, &kernel_tp);
|
||||||
|
|
||||||
if (!error && copy_to_user(tp, &kernel_tp, sizeof (kernel_tp)))
|
if (!error && copy_to_user(tp, &kernel_tp, sizeof (kernel_tp)))
|
||||||
error = -EFAULT;
|
error = -EFAULT;
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
|
SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
|
||||||
|
|
Loading…
Add table
Reference in a new issue