From 04c227140fed77587432667a574b14736a06dd7f Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Mon, 15 Oct 2007 16:06:04 -0500 Subject: hrtimer: Rework hrtimer_nanosleep to make sys_compat_nanosleep easier Pull the copy_to_user out of hrtimer_nanosleep and into the callers (common_nsleep, sys_nanosleep) in preparation for converting compat_sys_nanosleep to use hrtimers. Signed-off-by: Anton Blanchard Acked-by: Arnd Bergmann Signed-off-by: Thomas Gleixner --- kernel/posix-timers.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'kernel/posix-timers.c') diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index d71ed09..d11f579 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c @@ -981,9 +981,20 @@ sys_clock_getres(const clockid_t which_clock, struct timespec __user *tp) static int common_nsleep(const clockid_t which_clock, int flags, struct timespec *tsave, struct timespec __user *rmtp) { - return hrtimer_nanosleep(tsave, rmtp, flags & TIMER_ABSTIME ? - HRTIMER_MODE_ABS : HRTIMER_MODE_REL, - which_clock); + struct timespec rmt; + int ret; + + ret = hrtimer_nanosleep(tsave, rmtp ? &rmt : NULL, + flags & TIMER_ABSTIME ? + HRTIMER_MODE_ABS : HRTIMER_MODE_REL, + which_clock); + + if (ret && rmtp) { + if (copy_to_user(rmtp, &rmt, sizeof(*rmtp))) + return -EFAULT; + } + + return ret; } asmlinkage long -- cgit v1.1