linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linaro.org>
To: tglx@linutronix.de
Cc: arnd@arndb.de, linux-kernel@vger.kernel.org,
	baolin.wang@linaro.org, y2038@lists.linaro.org
Subject: [PATCH v4 09/25] posix-timers:Change the implementation for timer_settime syscall
Date: Mon,  1 Jun 2015 19:56:09 +0800	[thread overview]
Message-ID: <1433159769-4890-1-git-send-email-baolin.wang@linaro.org> (raw)

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 |   41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 2adeb29..99ccb3c 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -920,27 +920,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)
@@ -950,14 +941,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


                 reply	other threads:[~2015-06-01 11:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1433159769-4890-1-git-send-email-baolin.wang@linaro.org \
    --to=baolin.wang@linaro.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=y2038@lists.linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).