Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752962Ab0KDT3T (ORCPT ); Thu, 4 Nov 2010 15:29:19 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:42120 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752934Ab0KDT3Q (ORCPT ); Thu, 4 Nov 2010 15:29:16 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=N815VxBAxoQo2f6Bm78mizuD1v8nHizyeyeT2qM4AoedRdR7y0GFc+/LqfWVx1eFT/ G+yBwxDPJIlZtECsQRxjQ6ATFWsOdkKjkrW+WeQ6ehLYDnNtGVSMJ8OprIG8ZHx+n4VY Q7/Icn/ZruxiJ4oVZaia68gjNxarIWHddGQAA= Date: Thu, 4 Nov 2010 20:29:13 +0100 From: Richard Cochran To: linux-kernel@vger.kernel.org Cc: linux-api@vger.kernel.org, Alan Cox , Arnd Bergmann , Christoph Lameter , John Stultz , Peter Zijlstra , Thomas Gleixner Subject: [PATCH RFC 4/8] clock device: convert clock_settime Message-ID: <539a5244b2cc2319aa9054b25bb00dc4713b740d.1288897199.git.richard.cochran@omicron.at> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2427 Lines: 77 This patch lets the clock_settime system call use dynamic clock devices. Signed-off-by: Richard Cochran --- include/linux/posix-timers.h | 1 + kernel/posix-timers.c | 4 ++-- kernel/time/clockdevice.c | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index 7d6a4f0..864ed7b 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -138,5 +138,6 @@ void update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new); int posix_clock_gettime(const clockid_t clock, struct timespec __user *tp); int posix_clock_getres(const clockid_t clock, struct timespec __user *tp); +int posix_clock_settime(const clockid_t clock, const struct timespec __user *t); #endif diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index baa6a2e..ef4e222 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c @@ -939,8 +939,8 @@ int do_posix_clock_nonanosleep(const clockid_t clock, int flags, } EXPORT_SYMBOL_GPL(do_posix_clock_nonanosleep); -SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock, - const struct timespec __user *, tp) +int posix_clock_settime(const clockid_t which_clock, + const struct timespec __user *tp) { struct timespec new_tp; diff --git a/kernel/time/clockdevice.c b/kernel/time/clockdevice.c index 6629ae7..3f2870d 100644 --- a/kernel/time/clockdevice.c +++ b/kernel/time/clockdevice.c @@ -238,3 +238,29 @@ SYSCALL_DEFINE2(clock_getres, mutex_unlock(&clk->mux); return err; } + +SYSCALL_DEFINE2(clock_settime, + const clockid_t, id, const struct timespec __user *, user_ts) +{ + struct timespec ts; + struct clock_device *clk; + int err; + + clk = clockid_to_clock_device(id); + if (!clk) + return posix_clock_settime(id, user_ts); + + mutex_lock(&clk->mux); + + if (clk->zombie) + err = -ENODEV; + else if (!clk->ops->clock_settime) + err = -EOPNOTSUPP; + else if (copy_from_user(&ts, user_ts, sizeof(ts))) + err = -EFAULT; + else + err = clk->ops->clock_settime(clk->priv, &ts); + + mutex_unlock(&clk->mux); + return err; +} -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/