From: Thomas Gleixner When CONFIG_GENERIC_TIME is enabled use the ktime_t based interfaces of timeofday. Also disable the timespec based interfaces in hrtimers and use the timeofday interfaces directly. Signed-off-by: Thomas Gleixner Cc: john stultz Signed-off-by: Andrew Morton --- include/linux/hrtimer.h | 1 include/linux/ktime.h | 11 +++++++++ kernel/hrtimer.c | 46 +++++++++++++++++++------------------- kernel/time/timeofday.c | 2 + 4 files changed, 38 insertions(+), 22 deletions(-) diff -puN include/linux/hrtimer.h~time-generic-timekeeping-infrastructure-use-generic-timeofday-interfaces-in-hrtimer--ktime include/linux/hrtimer.h --- 25/include/linux/hrtimer.h~time-generic-timekeeping-infrastructure-use-generic-timeofday-interfaces-in-hrtimer--ktime Thu Jan 12 17:26:05 2006 +++ 25-akpm/include/linux/hrtimer.h Thu Jan 12 17:26:05 2006 @@ -20,6 +20,7 @@ #include #include #include +#include /* * Mode arguments of xxx_hrtimer functions: diff -puN include/linux/ktime.h~time-generic-timekeeping-infrastructure-use-generic-timeofday-interfaces-in-hrtimer--ktime include/linux/ktime.h --- 25/include/linux/ktime.h~time-generic-timekeeping-infrastructure-use-generic-timeofday-interfaces-in-hrtimer--ktime Thu Jan 12 17:26:05 2006 +++ 25-akpm/include/linux/ktime.h Thu Jan 12 17:26:05 2006 @@ -275,10 +275,21 @@ static inline u64 ktime_to_ns(const ktim #define KTIME_REALTIME_RES (ktime_t){ .tv64 = TICK_NSEC } #define KTIME_MONOTONIC_RES (ktime_t){ .tv64 = TICK_NSEC } +#ifdef CONFIG_GENERIC_TIME + +#define ktime_get get_monotonic_clock +#define ktime_get_real get_realtime_clock +#define ktime_get_ts(ts) get_monotonic_clock_ts(ts) +#define ktime_get_real_ts(ts) get_realtime_clock_ts(ts) + +#else /* CONFIG_GENERIC_TIME */ + /* Get the monotonic time in timespec format: */ extern void ktime_get_ts(struct timespec *ts); /* Get the real (wall-) time in timespec format: */ #define ktime_get_real_ts(ts) getnstimeofday(ts) +#endif /* !CONFIG_GENERIC_TIME */ + #endif diff -puN kernel/hrtimer.c~time-generic-timekeeping-infrastructure-use-generic-timeofday-interfaces-in-hrtimer--ktime kernel/hrtimer.c --- 25/kernel/hrtimer.c~time-generic-timekeeping-infrastructure-use-generic-timeofday-interfaces-in-hrtimer--ktime Thu Jan 12 17:26:05 2006 +++ 25-akpm/kernel/hrtimer.c Thu Jan 12 17:26:05 2006 @@ -29,12 +29,13 @@ #include #include #include -#include #include #include #include +#ifndef CONFIG_GENERIC_TIME + /** * ktime_get - get the monotonic time in ktime_t format * @@ -62,29 +63,8 @@ static ktime_t ktime_get_real(void) return timespec_to_ktime(now); } - EXPORT_SYMBOL_GPL(ktime_get_real); -/* - * The timer bases: - */ - -#define MAX_HRTIMER_BASES 2 - -static DEFINE_PER_CPU(struct hrtimer_base, hrtimer_bases[MAX_HRTIMER_BASES]) = -{ - { - .index = CLOCK_REALTIME, - .get_time = &ktime_get_real, - .resolution = KTIME_REALTIME_RES, - }, - { - .index = CLOCK_MONOTONIC, - .get_time = &ktime_get, - .resolution = KTIME_MONOTONIC_RES, - }, -}; - /** * ktime_get_ts - get the monotonic clock in timespec format * @@ -111,6 +91,28 @@ void ktime_get_ts(struct timespec *ts) } EXPORT_SYMBOL_GPL(ktime_get_ts); +#endif + +/* + * The timer bases: + */ + +#define MAX_HRTIMER_BASES 2 + +static DEFINE_PER_CPU(struct hrtimer_base, hrtimer_bases[MAX_HRTIMER_BASES]) = +{ + { + .index = CLOCK_REALTIME, + .get_time = &ktime_get_real, + .resolution = KTIME_REALTIME_RES, + }, + { + .index = CLOCK_MONOTONIC, + .get_time = &ktime_get, + .resolution = KTIME_MONOTONIC_RES, + }, +}; + /* * Functions and macros which are different for UP/SMP systems are kept in a * single place diff -puN kernel/time/timeofday.c~time-generic-timekeeping-infrastructure-use-generic-timeofday-interfaces-in-hrtimer--ktime kernel/time/timeofday.c --- 25/kernel/time/timeofday.c~time-generic-timekeeping-infrastructure-use-generic-timeofday-interfaces-in-hrtimer--ktime Thu Jan 12 17:26:05 2006 +++ 25-akpm/kernel/time/timeofday.c Thu Jan 12 17:26:05 2006 @@ -238,6 +238,8 @@ ktime_t get_realtime_clock(void) return ret; } +EXPORT_SYMBOL_GPL(get_realtime_clock); + /** * get_realtime_offset - Returns the offset of realtime clock * _