lkml.org 
[lkml]   [2015]   [May]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 06/22] posix-timers:Split out the guts of the syscall and change the implementation for timer_settime
Date
This patch splits out the guts of the timer_settime syscall and changes the
timer_settime syscall implementation to prepare the converting to 64bit methods
for the timer_settime syscall function in posix-timers.c file.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
kernel/time/posix-timers.c | 45 +++++++++++++++++++++++++++-----------------
1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index f7cf00b..0ec9647 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -899,27 +899,14 @@ common_timer_set(struct k_itimer *timr, int flags,
return 0;
}

-/* Set a POSIX.1b interval timer */
-SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags,
- const struct itimerspec __user *, new_setting,
- struct itimerspec __user *, old_setting)
+static int __timer_settime(timer_t timer_id, int flags, struct itimerspec *new_spec,
+ struct itimerspec *old_spec)
{
struct k_itimer *timr;
- struct itimerspec new_spec, old_spec;
int error = 0;
unsigned long flag;
- struct itimerspec *rtn = old_setting ? &old_spec : NULL;
struct k_clock *kc;

- if (!new_setting)
- return -EINVAL;
-
- if (copy_from_user(&new_spec, new_setting, sizeof (new_spec)))
- return -EFAULT;
-
- if (!timespec_valid(&new_spec.it_interval) ||
- !timespec_valid(&new_spec.it_value))
- return -EINVAL;
retry:
timr = lock_timer(timer_id, &flag);
if (!timr)
@@ -929,14 +916,38 @@ retry:
if (WARN_ON_ONCE(!kc || !kc->timer_set))
error = -EINVAL;
else
- error = kc->timer_set(timr, flags, &new_spec, rtn);
+ error = kc->timer_set(timr, flags, new_spec, old_spec);

unlock_timer(timr, flag);
if (error == TIMER_RETRY) {
- rtn = NULL; // We already got the old time...
+ old_spec = NULL; // We already got the old time...
goto retry;
}

+ return error;
+}
+
+/* Set a POSIX.1b interval timer */
+SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags,
+ const struct itimerspec __user *, new_setting,
+ struct itimerspec __user *, old_setting)
+{
+ struct itimerspec new_spec, old_spec;
+ int error = 0;
+ struct itimerspec *rtn = old_setting ? &old_spec : NULL;
+
+ if (!new_setting)
+ return -EINVAL;
+
+ if (copy_from_user(&new_spec, new_setting, sizeof (new_spec)))
+ return -EFAULT;
+
+ if (!timespec_valid(&new_spec.it_interval) ||
+ !timespec_valid(&new_spec.it_value))
+ return -EINVAL;
+
+ error = __timer_settime(timer_id, flags, &new_spec, rtn);
+
if (old_setting && !error &&
copy_to_user(old_setting, &old_spec, sizeof (old_spec)))
error = -EFAULT;
--
1.7.9.5


\
 
 \ /
  Last update: 2015-05-11 13:21    [W:0.028 / U:10.924 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site