aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time/timekeeping.c
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2012-11-07 19:58:54 -0500
committerStephen Warren <swarren@nvidia.com>2012-12-24 11:36:07 -0500
commit7b1f62076bba10786d2118006ae68ac120cd6c56 (patch)
tree9af9f556fc331c77644c2e1c4eafdddad60019b1 /kernel/time/timekeeping.c
parent547046f2f09f1837d39619afbc7a6e35673d7c98 (diff)
time: convert arch_gettimeoffset to a pointer
Currently, whenever CONFIG_ARCH_USES_GETTIMEOFFSET is enabled, each arch core provides a single implementation of arch_gettimeoffset(). In many cases, different sub-architectures, different machines, or different timer providers exist, and so the arch ends up implementing arch_gettimeoffset() as a call-through-pointer anyway. Examples are ARM, Cris, M68K, and it's arguable that the remaining architectures, M32R and Blackfin, should be doing this anyway. Modify arch_gettimeoffset so that it itself is a function pointer, which the arch initializes. This will allow later changes to move the initialization of this function into individual machine support or timer drivers. This is particularly useful for code in drivers/clocksource which should rely on an arch-independant mechanism to register their implementation of arch_gettimeoffset(). This patch also converts the Cris architecture to set arch_gettimeoffset directly to the final implementation in time_init(), because Cris already had separate time_init() functions per sub-architecture. M68K and ARM are converted to set arch_gettimeoffset to the final implementation in later patches, because they already have function pointers in place for this purpose. Cc: Russell King <linux@arm.linux.org.uk> Cc: Mike Frysinger <vapier@gentoo.org> Cc: Mikael Starvik <starvik@axis.com> Cc: Hirokazu Takata <takata@linux-m32r.org> Cc: Thomas Gleixner <tglx@linutronix.de> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Jesper Nilsson <jesper.nilsson@axis.com> Acked-by: John Stultz <johnstul@us.ibm.com> Signed-off-by: Stephen Warren <swarren@nvidia.com>
Diffstat (limited to 'kernel/time/timekeeping.c')
-rw-r--r--kernel/time/timekeeping.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index cbc6acb0db3f..8ed934601587 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -135,6 +135,20 @@ static void tk_setup_internals(struct timekeeper *tk, struct clocksource *clock)
135} 135}
136 136
137/* Timekeeper helper functions. */ 137/* Timekeeper helper functions. */
138
139#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
140u32 (*arch_gettimeoffset)(void);
141
142u32 get_arch_timeoffset(void)
143{
144 if (likely(arch_gettimeoffset))
145 return arch_gettimeoffset();
146 return 0;
147}
148#else
149static inline u32 get_arch_timeoffset(void) { return 0; }
150#endif
151
138static inline s64 timekeeping_get_ns(struct timekeeper *tk) 152static inline s64 timekeeping_get_ns(struct timekeeper *tk)
139{ 153{
140 cycle_t cycle_now, cycle_delta; 154 cycle_t cycle_now, cycle_delta;
@@ -151,8 +165,8 @@ static inline s64 timekeeping_get_ns(struct timekeeper *tk)
151 nsec = cycle_delta * tk->mult + tk->xtime_nsec; 165 nsec = cycle_delta * tk->mult + tk->xtime_nsec;
152 nsec >>= tk->shift; 166 nsec >>= tk->shift;
153 167
154 /* If arch requires, add in gettimeoffset() */ 168 /* If arch requires, add in get_arch_timeoffset() */
155 return nsec + arch_gettimeoffset(); 169 return nsec + get_arch_timeoffset();
156} 170}
157 171
158static inline s64 timekeeping_get_ns_raw(struct timekeeper *tk) 172static inline s64 timekeeping_get_ns_raw(struct timekeeper *tk)
@@ -171,8 +185,8 @@ static inline s64 timekeeping_get_ns_raw(struct timekeeper *tk)
171 /* convert delta to nanoseconds. */ 185 /* convert delta to nanoseconds. */
172 nsec = clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift); 186 nsec = clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift);
173 187
174 /* If arch requires, add in gettimeoffset() */ 188 /* If arch requires, add in get_arch_timeoffset() */
175 return nsec + arch_gettimeoffset(); 189 return nsec + get_arch_timeoffset();
176} 190}
177 191
178static RAW_NOTIFIER_HEAD(pvclock_gtod_chain); 192static RAW_NOTIFIER_HEAD(pvclock_gtod_chain);
@@ -254,8 +268,8 @@ static void timekeeping_forward_now(struct timekeeper *tk)
254 268
255 tk->xtime_nsec += cycle_delta * tk->mult; 269 tk->xtime_nsec += cycle_delta * tk->mult;
256 270
257 /* If arch requires, add in gettimeoffset() */ 271 /* If arch requires, add in get_arch_timeoffset() */
258 tk->xtime_nsec += (u64)arch_gettimeoffset() << tk->shift; 272 tk->xtime_nsec += (u64)get_arch_timeoffset() << tk->shift;
259 273
260 tk_normalize_xtime(tk); 274 tk_normalize_xtime(tk);
261 275