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 <[email protected]>
Cc: John Stultz <[email protected]>
Cc: Richard Cochran <[email protected]>
---
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,
On Tue, 2011-02-01 at 13:51 +0000, Thomas Gleixner wrote:
> plain text document attachment
> (posix-timers-introduce-clockid-to-kclock.patch)
> 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 <[email protected]>
> Cc: John Stultz <[email protected]>
> Cc: Richard Cochran <[email protected]>
Acked-by: John Stultz <[email protected]>
Commit-ID: cc785ac22b17ed53e8ff5c1501e422be6d10be3c
Gitweb: http://git.kernel.org/tip/cc785ac22b17ed53e8ff5c1501e422be6d10be3c
Author: Thomas Gleixner <[email protected]>
AuthorDate: Tue, 1 Feb 2011 13:51:09 +0000
Committer: Thomas Gleixner <[email protected]>
CommitDate: Wed, 2 Feb 2011 15:28:12 +0100
posix-timers: Introduce clockid_to_kclock()
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
NULL. For valid clocks it returns a pointer to the matching
posix_clock.
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: John Stultz <[email protected]>
Acked-by: Richard Cochran <[email protected]>
LKML-Reference: <[email protected]>
---
kernel/posix-timers.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index e7d26af..14b0a70 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -531,6 +531,16 @@ static void release_posix_timer(struct k_itimer *tmr, int it_id_set)
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,