One new API call clocksource_get_clock() which allows clocks to be selected
based on their name, or if the name is null the highest rated clock is returned.
Signed-Off-By: Daniel Walker <[email protected]>
---
include/linux/clocksource.h | 12 ++++++++++++
kernel/time/clocksource.c | 18 ++++++++++++++++++
2 files changed, 30 insertions(+)
Index: linux-2.6.19/include/linux/clocksource.h
===================================================================
--- linux-2.6.19.orig/include/linux/clocksource.h
+++ linux-2.6.19/include/linux/clocksource.h
@@ -234,6 +234,18 @@ static inline void clocksource_calculate
extern struct clocksource *clocksource_get_next(void);
extern int clocksource_register(struct clocksource*);
extern void clocksource_rating_change(struct clocksource*);
+extern struct clocksource * clocksource_get_clock(char*);
+
+/**
+ * clocksource_get_best_clock - Finds highest rated clocksource
+ *
+ * Returns the highest rated clocksource. If none are register the
+ * jiffies clock is returned.
+ */
+static inline struct clocksource * clocksource_get_best_clock(void)
+{
+ return clocksource_get_clock(NULL);
+}
#ifdef CONFIG_GENERIC_TIME_VSYSCALL
extern void update_vsyscall(struct timespec *ts, struct clocksource *c);
Index: linux-2.6.19/kernel/time/clocksource.c
===================================================================
--- linux-2.6.19.orig/kernel/time/clocksource.c
+++ linux-2.6.19/kernel/time/clocksource.c
@@ -132,6 +132,24 @@ static inline struct clocksource * __get
}
/**
+ * clocksource_get_clock - Finds a specific clocksource
+ * @name: name of the clocksource to return
+ *
+ * Returns the clocksource if registered, zero otherwise.
+ */
+struct clocksource * clocksource_get_clock(char * name)
+{
+ struct clocksource * ret;
+ unsigned long flags;
+
+ spin_lock_irqsave(&clocksource_lock, flags);
+ ret = __get_clock(name);
+ spin_unlock_irqrestore(&clocksource_lock, flags);
+ return ret;
+}
+
+
+/**
* select_clocksource - Finds the best registered clocksource.
*
* Private function. Must hold clocksource_lock when called.
--
* Daniel Walker <[email protected]> wrote:
> One new API call clocksource_get_clock() which allows clocks to be
> selected based on their name, or if the name is null the highest rated
> clock is returned.
this one (and the dependent APIs utilizations) look a step in the right
direction to me, but they are not fully consequent and thus a bit
confusing at the moment:
- the current_clocksource is now something that is conceptually related
to timekeeping - while it still resides in the clocksource domain.
- if we do this split there should be a separate sysfs hierarchy for
timekeeping, separate of clocksource
- you use struct sys_device clocksource_sys_device from clocksource.c in
timekeeping.c, which is inconsistent as well.
so these bits need more work.
Ingo
On Wed, 2007-01-31 at 12:46 +0100, Ingo Molnar wrote:
> * Daniel Walker <[email protected]> wrote:
>
> > One new API call clocksource_get_clock() which allows clocks to be
> > selected based on their name, or if the name is null the highest rated
> > clock is returned.
>
> this one (and the dependent APIs utilizations) look a step in the right
> direction to me, but they are not fully consequent and thus a bit
> confusing at the moment:
>
> - the current_clocksource is now something that is conceptually related
> to timekeeping - while it still resides in the clocksource domain.
Yes . The sysfs code gets moved in the next patch so it resides in the
timekeeping code ..
> - if we do this split there should be a separate sysfs hierarchy for
> timekeeping, separate of clocksource
A long time ago I changed "current_clocksource" to
"timekeeping_clocksource" which made sense at the time .. I got push
back on that from John, and I think maybe Thomas ..
> - you use struct sys_device clocksource_sys_device from clocksource.c in
> timekeeping.c, which is inconsistent as well.
>
This was on purpose , because I feel the sysfs organization benefits
when you have the clocksource users all in one place. Along with the
list of available clocksources .. I'm all ears if you have a better
suggestion ..
Daniel