diff options
author | John Stultz <john.stultz@linaro.org> | 2013-01-21 20:00:11 -0500 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2013-03-22 19:19:59 -0400 |
commit | 90adda98b89aaf68b06014ecf805b6c477daa19b (patch) | |
tree | c50d47c4c344774205569ce42e13d16a8174b02e /kernel/time/timekeeping.c | |
parent | 1ff3c9677bff7e468e0c487d0ffefe4e901d33f4 (diff) |
hrtimer: Add hrtimer support for CLOCK_TAI
Add hrtimer support for CLOCK_TAI, as well as posix timer interfaces.
Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'kernel/time/timekeeping.c')
-rw-r--r-- | kernel/time/timekeeping.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 8a842756572d..8061ae0be7bd 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -67,6 +67,7 @@ static void tk_set_wall_to_mono(struct timekeeper *tk, struct timespec wtm) | |||
67 | tk->wall_to_monotonic = wtm; | 67 | tk->wall_to_monotonic = wtm; |
68 | set_normalized_timespec(&tmp, -wtm.tv_sec, -wtm.tv_nsec); | 68 | set_normalized_timespec(&tmp, -wtm.tv_sec, -wtm.tv_nsec); |
69 | tk->offs_real = timespec_to_ktime(tmp); | 69 | tk->offs_real = timespec_to_ktime(tmp); |
70 | tk->offs_tai = ktime_sub(tk->offs_real, ktime_set(tk->tai_offset, 0)); | ||
70 | } | 71 | } |
71 | 72 | ||
72 | static void tk_set_sleep_time(struct timekeeper *tk, struct timespec t) | 73 | static void tk_set_sleep_time(struct timekeeper *tk, struct timespec t) |
@@ -409,6 +410,20 @@ void timekeeping_clocktai(struct timespec *ts) | |||
409 | EXPORT_SYMBOL(timekeeping_clocktai); | 410 | EXPORT_SYMBOL(timekeeping_clocktai); |
410 | 411 | ||
411 | 412 | ||
413 | /** | ||
414 | * ktime_get_clocktai - Returns the TAI time of day in a ktime | ||
415 | * | ||
416 | * Returns the time of day in a ktime. | ||
417 | */ | ||
418 | ktime_t ktime_get_clocktai(void) | ||
419 | { | ||
420 | struct timespec ts; | ||
421 | |||
422 | timekeeping_clocktai(&ts); | ||
423 | return timespec_to_ktime(ts); | ||
424 | } | ||
425 | EXPORT_SYMBOL(ktime_get_clocktai); | ||
426 | |||
412 | #ifdef CONFIG_NTP_PPS | 427 | #ifdef CONFIG_NTP_PPS |
413 | 428 | ||
414 | /** | 429 | /** |
@@ -569,6 +584,7 @@ s32 timekeeping_get_tai_offset(void) | |||
569 | void __timekeeping_set_tai_offset(struct timekeeper *tk, s32 tai_offset) | 584 | void __timekeeping_set_tai_offset(struct timekeeper *tk, s32 tai_offset) |
570 | { | 585 | { |
571 | tk->tai_offset = tai_offset; | 586 | tk->tai_offset = tai_offset; |
587 | tk->offs_tai = ktime_sub(tk->offs_real, ktime_set(tai_offset, 0)); | ||
572 | } | 588 | } |
573 | 589 | ||
574 | /** | 590 | /** |
@@ -1539,7 +1555,8 @@ void get_xtime_and_monotonic_and_sleep_offset(struct timespec *xtim, | |||
1539 | * Returns current monotonic time and updates the offsets | 1555 | * Returns current monotonic time and updates the offsets |
1540 | * Called from hrtimer_interupt() or retrigger_next_event() | 1556 | * Called from hrtimer_interupt() or retrigger_next_event() |
1541 | */ | 1557 | */ |
1542 | ktime_t ktime_get_update_offsets(ktime_t *offs_real, ktime_t *offs_boot) | 1558 | ktime_t ktime_get_update_offsets(ktime_t *offs_real, ktime_t *offs_boot, |
1559 | ktime_t *offs_tai) | ||
1543 | { | 1560 | { |
1544 | struct timekeeper *tk = &timekeeper; | 1561 | struct timekeeper *tk = &timekeeper; |
1545 | ktime_t now; | 1562 | ktime_t now; |
@@ -1554,6 +1571,7 @@ ktime_t ktime_get_update_offsets(ktime_t *offs_real, ktime_t *offs_boot) | |||
1554 | 1571 | ||
1555 | *offs_real = tk->offs_real; | 1572 | *offs_real = tk->offs_real; |
1556 | *offs_boot = tk->offs_boot; | 1573 | *offs_boot = tk->offs_boot; |
1574 | *offs_tai = tk->offs_tai; | ||
1557 | } while (read_seqretry(&tk->lock, seq)); | 1575 | } while (read_seqretry(&tk->lock, seq)); |
1558 | 1576 | ||
1559 | now = ktime_add_ns(ktime_set(secs, 0), nsecs); | 1577 | now = ktime_add_ns(ktime_set(secs, 0), nsecs); |