diff options
author | John Stultz <johnstul@us.ibm.com> | 2010-05-07 21:07:38 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2010-05-10 08:24:26 -0400 |
commit | d7e81c269db899b800e0963dc4aceece1f82a680 (patch) | |
tree | bf30c8c5ed86dbf3c71a25e0f3ab1093c19e516f /include/linux/clocksource.h | |
parent | 29f87b793da421a6ab816d991dc8dbf909dfb66a (diff) |
clocksource: Add clocksource_register_hz/khz interface
How to pick good mult/shift pairs has always been difficult to
describe to folks writing clocksource drivers, since it requires
careful tradeoffs in adjustment accuracy vs overflow limits.
Now, with the clocks_calc_mult_shift function, its much
easier. However, not many clocksources have converted to using that
function, and there is still the issue of the max interval length
assumption being made by each clocksource driver independently.
So this patch simplifies the registration process by having
clocksources be registered with a hz/khz value and the registration
function taking care of setting mult/shift.
This should take most of the confusion out of writing a clocksource
driver.
Additionally it also keeps the shift size tradeoff (more accuracy vs
longer possible nohz times) centralized so the timekeeping core can
keep track of the assumptions being made.
[ tglx: Coding style and comments fixed ]
Signed-off-by: John Stultz <johnstul@us.ibm.com>
LKML-Reference: <1273280858-30143-1-git-send-email-johnstul@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/linux/clocksource.h')
-rw-r--r-- | include/linux/clocksource.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h index 4bca8b60cdf7..5ea3c60c160c 100644 --- a/include/linux/clocksource.h +++ b/include/linux/clocksource.h | |||
@@ -273,7 +273,6 @@ static inline s64 clocksource_cyc2ns(cycle_t cycles, u32 mult, u32 shift) | |||
273 | } | 273 | } |
274 | 274 | ||
275 | 275 | ||
276 | /* used to install a new clocksource */ | ||
277 | extern int clocksource_register(struct clocksource*); | 276 | extern int clocksource_register(struct clocksource*); |
278 | extern void clocksource_unregister(struct clocksource*); | 277 | extern void clocksource_unregister(struct clocksource*); |
279 | extern void clocksource_touch_watchdog(void); | 278 | extern void clocksource_touch_watchdog(void); |
@@ -287,6 +286,24 @@ extern void clocksource_mark_unstable(struct clocksource *cs); | |||
287 | extern void | 286 | extern void |
288 | clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 minsec); | 287 | clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 minsec); |
289 | 288 | ||
289 | /* | ||
290 | * Don't call __clocksource_register_scale directly, use | ||
291 | * clocksource_register_hz/khz | ||
292 | */ | ||
293 | extern int | ||
294 | __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq); | ||
295 | |||
296 | static inline int clocksource_register_hz(struct clocksource *cs, u32 hz) | ||
297 | { | ||
298 | return __clocksource_register_scale(cs, 1, hz); | ||
299 | } | ||
300 | |||
301 | static inline int clocksource_register_khz(struct clocksource *cs, u32 khz) | ||
302 | { | ||
303 | return __clocksource_register_scale(cs, 1000, khz); | ||
304 | } | ||
305 | |||
306 | |||
290 | static inline void | 307 | static inline void |
291 | clocksource_calc_mult_shift(struct clocksource *cs, u32 freq, u32 minsec) | 308 | clocksource_calc_mult_shift(struct clocksource *cs, u32 freq, u32 minsec) |
292 | { | 309 | { |