Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757196Ab1BAN4v (ORCPT ); Tue, 1 Feb 2011 08:56:51 -0500 Received: from www.tglx.de ([62.245.132.106]:47114 "EHLO www.tglx.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756983Ab1BANvW (ORCPT ); Tue, 1 Feb 2011 08:51:22 -0500 Message-Id: <20110201134417.938447839@linutronix.de> User-Agent: quilt/0.48-1 Date: Tue, 01 Feb 2011 13:51:09 -0000 From: Thomas Gleixner To: LKML Cc: John Stultz , Richard Cochran , Ingo Molnar , Peter Zijlstra Subject: [patch 05/28] posix-timers: Introduce clockid_to_kclock() References: <20110201134320.688829863@linutronix.de> Content-Disposition: inline; filename=posix-timers-introduce-clockid-to-kclock.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1356 Lines: 42 New function to find the kclock for a given clockid. Returns a pointer to clock_posix_cpu if clockid < 0. If clockid >= MAXCLOCK or if the clock_getres pointer is not set it returns -EINVAL. For valid clocks it returns a pointer to the matching posix_clock. Signed-off-by: Thomas Gleixner Cc: John Stultz Cc: Richard Cochran --- kernel/posix-timers.c | 10 ++++++++++ 1 file changed, 10 insertions(+) Index: linux-2.6-tip/kernel/posix-timers.c =================================================================== --- linux-2.6-tip.orig/kernel/posix-timers.c +++ linux-2.6-tip/kernel/posix-timers.c @@ -531,6 +531,16 @@ static void release_posix_timer(struct k kmem_cache_free(posix_timers_cache, tmr); } +static struct k_clock *clockid_to_kclock(const clockid_t id) +{ + if (id < 0) + return &clock_posix_cpu; + + if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres) + return NULL; + return &posix_clocks[id]; +} + /* Create a POSIX.1b interval timer. */ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock, -- 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/