[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <2644cc39311ba0a5d2328710a40e8f0a8d5ebd1e.1434079263.git.baolin.wang@linaro.org>
Date: Fri, 12 Jun 2015 15:48:23 +0800
From: Baolin Wang <baolin.wang@...aro.org>
To: tglx@...utronix.de
Cc: arnd@...db.de, linux-kernel@...r.kernel.org,
baolin.wang@...aro.org, y2038@...ts.linaro.org
Subject: [PATCH v5 08/24] posix-timers: Factor out the guts of 'timer_settime' for reusing
In order to reuse the very same logic for the year 2038 safe syscalls
which we need to introduce for 32bit system, factor out the guts of
the 'timer_settime' syscall.
Signed-off-by: Baolin Wang <baolin.wang@...aro.org>
---
kernel/time/posix-timers.c | 41 ++++++++++++++++++++++++++---------------
1 file changed, 26 insertions(+), 15 deletions(-)
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 70b5550..2f1c26f 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -927,27 +927,18 @@ 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)
+ if (!timespec_valid(&new_spec->it_interval) ||
+ !timespec_valid(&new_spec->it_value))
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)
@@ -957,14 +948,34 @@ 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;
+
+ 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists