diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2009-07-07 07:00:31 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2009-07-07 07:00:31 -0400 |
commit | a40f262cc21fbfd781bbddcc40b16b83a75f5f34 (patch) | |
tree | 1600f58173be05f561bcad045bca4014ab635d6f /kernel/time | |
parent | 951ed4d36b77ba9fe1ea08fc3c59d8bb6c9bda32 (diff) |
timekeeping: Move ktime_get() functions to timekeeping.c
The ktime_get() functions for GENERIC_TIME=n are still located in
hrtimer.c. Move them to time/timekeeping.c where they belong.
LKML-Reference: <new-submission>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/time')
-rw-r--r-- | kernel/time/timekeeping.c | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 7a248135c6f2..02c0b2c9c674 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -290,10 +290,65 @@ static void change_clocksource(void) | |||
290 | clock->name); | 290 | clock->name); |
291 | */ | 291 | */ |
292 | } | 292 | } |
293 | #else | 293 | #else /* GENERIC_TIME */ |
294 | static inline void clocksource_forward_now(void) { } | 294 | static inline void clocksource_forward_now(void) { } |
295 | static inline void change_clocksource(void) { } | 295 | static inline void change_clocksource(void) { } |
296 | #endif | 296 | |
297 | /** | ||
298 | * ktime_get - get the monotonic time in ktime_t format | ||
299 | * | ||
300 | * returns the time in ktime_t format | ||
301 | */ | ||
302 | ktime_t ktime_get(void) | ||
303 | { | ||
304 | struct timespec now; | ||
305 | |||
306 | ktime_get_ts(&now); | ||
307 | |||
308 | return timespec_to_ktime(now); | ||
309 | } | ||
310 | EXPORT_SYMBOL_GPL(ktime_get); | ||
311 | |||
312 | /** | ||
313 | * ktime_get_ts - get the monotonic clock in timespec format | ||
314 | * @ts: pointer to timespec variable | ||
315 | * | ||
316 | * The function calculates the monotonic clock from the realtime | ||
317 | * clock and the wall_to_monotonic offset and stores the result | ||
318 | * in normalized timespec format in the variable pointed to by @ts. | ||
319 | */ | ||
320 | void ktime_get_ts(struct timespec *ts) | ||
321 | { | ||
322 | struct timespec tomono; | ||
323 | unsigned long seq; | ||
324 | |||
325 | do { | ||
326 | seq = read_seqbegin(&xtime_lock); | ||
327 | getnstimeofday(ts); | ||
328 | tomono = wall_to_monotonic; | ||
329 | |||
330 | } while (read_seqretry(&xtime_lock, seq)); | ||
331 | |||
332 | set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec, | ||
333 | ts->tv_nsec + tomono.tv_nsec); | ||
334 | } | ||
335 | EXPORT_SYMBOL_GPL(ktime_get_ts); | ||
336 | #endif /* !GENERIC_TIME */ | ||
337 | |||
338 | /** | ||
339 | * ktime_get_real - get the real (wall-) time in ktime_t format | ||
340 | * | ||
341 | * returns the time in ktime_t format | ||
342 | */ | ||
343 | ktime_t ktime_get_real(void) | ||
344 | { | ||
345 | struct timespec now; | ||
346 | |||
347 | getnstimeofday(&now); | ||
348 | |||
349 | return timespec_to_ktime(now); | ||
350 | } | ||
351 | EXPORT_SYMBOL_GPL(ktime_get_real); | ||
297 | 352 | ||
298 | /** | 353 | /** |
299 | * getrawmonotonic - Returns the raw monotonic time in a timespec | 354 | * getrawmonotonic - Returns the raw monotonic time in a timespec |