Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753049Ab0KDT3l (ORCPT ); Thu, 4 Nov 2010 15:29:41 -0400 Received: from mail-gw0-f46.google.com ([74.125.83.46]:64035 "EHLO mail-gw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752903Ab0KDT3h (ORCPT ); Thu, 4 Nov 2010 15:29:37 -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=gyf8YkTTxauPV4gYQ+givtsj+oM/0EGtgFJTjG/gdIUq+ihwwNOfAEOBSY8El/q/ee YzQYG9CMVkH7bwXNT8c4PJHp6TM/J9cnG2MD+t2RVz0a9W33VqAASJ07dniP9LYTx3Cq n6OGRB4OTBERswP2sWCvH+JQrpUdGKjOsv0Fk= Date: Thu, 4 Nov 2010 20:29:34 +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 5/8] clock device: convert timer_create Message-ID: <996249855b4c2b680bedddf8a4e825a9d7eca3e5.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: 2852 Lines: 98 This patch lets the timer_create system call use dynamic clock devices. Signed-off-by: Richard Cochran --- include/linux/clockdevice.h | 5 +++++ kernel/posix-timers.c | 12 ++++++++++-- kernel/time/clockdevice.c | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/include/linux/clockdevice.h b/include/linux/clockdevice.h index ae258ac..3201a28 100644 --- a/include/linux/clockdevice.h +++ b/include/linux/clockdevice.h @@ -103,4 +103,9 @@ void *clock_device_private(struct file *fp); */ struct clock_device *clockid_to_clock_device(clockid_t id); +/* + * The following functions are only to be called from posix-timers.c + */ +int clock_device_timer_create(struct clock_device *clk, struct k_itimer *kit); + #endif diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index ef4e222..42efbe9 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -523,12 +524,15 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock, struct sigevent __user *, timer_event_spec, timer_t __user *, created_timer_id) { + struct clock_device *clk_dev; struct k_itimer *new_timer; int error, new_timer_id; sigevent_t event; int it_id_set = IT_ID_NOT_SET; - if (invalid_clockid(which_clock)) + clk_dev = clockid_to_clock_device(which_clock); + + if (!clk_dev && invalid_clockid(which_clock)) return -EINVAL; new_timer = alloc_posix_timer(); @@ -591,7 +595,11 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock, goto out; } - error = CLOCK_DISPATCH(which_clock, timer_create, (new_timer)); + if (clk_dev) + error = clock_device_timer_create(clk_dev, new_timer); + else { + error = CLOCK_DISPATCH(which_clock, timer_create, (new_timer)); + } if (error) goto out; diff --git a/kernel/time/clockdevice.c b/kernel/time/clockdevice.c index 3f2870d..166cc30 100644 --- a/kernel/time/clockdevice.c +++ b/kernel/time/clockdevice.c @@ -264,3 +264,20 @@ SYSCALL_DEFINE2(clock_settime, mutex_unlock(&clk->mux); return err; } + +int clock_device_timer_create(struct clock_device *clk, struct k_itimer *kit) +{ + int err; + + mutex_lock(&clk->mux); + + if (clk->zombie) + err = -ENODEV; + else if (!clk->ops->timer_create) + err = -EOPNOTSUPP; + else + err = clk->ops->timer_create(clk->priv, kit); + + 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/