diff options
author | john stultz <johnstul@us.ibm.com> | 2006-06-26 03:25:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-26 12:58:20 -0400 |
commit | 260a42309b31cbc54eb4b6b85649e412bcad053f (patch) | |
tree | 51efc7bb51075b0d25d0e8465d3c056e6a57fe16 /kernel | |
parent | ad596171ed635c51a9eef829187af100cbf8dcf7 (diff) |
[PATCH] Time: Let user request precision from current_tick_length()
Change the current_tick_length() function so it takes an argument which
specifies how much precision to return in shifted nanoseconds. This provides
a simple way to convert between NTPs internal nanoseconds shifted by
(SHIFT_SCALE - 10) to other shifted nanosecond units that are used by the
clocksource abstraction.
Signed-off-by: John Stultz <johnstul@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/timer.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/kernel/timer.c b/kernel/timer.c index 524c7f638365..623f9ea198d8 100644 --- a/kernel/timer.c +++ b/kernel/timer.c | |||
@@ -780,16 +780,29 @@ static void update_wall_time_one_tick(void) | |||
780 | * Return how long ticks are at the moment, that is, how much time | 780 | * Return how long ticks are at the moment, that is, how much time |
781 | * update_wall_time_one_tick will add to xtime next time we call it | 781 | * update_wall_time_one_tick will add to xtime next time we call it |
782 | * (assuming no calls to do_adjtimex in the meantime). | 782 | * (assuming no calls to do_adjtimex in the meantime). |
783 | * The return value is in fixed-point nanoseconds with SHIFT_SCALE-10 | 783 | * The return value is in fixed-point nanoseconds shifted by the |
784 | * bits to the right of the binary point. | 784 | * specified number of bits to the right of the binary point. |
785 | * This function has no side-effects. | 785 | * This function has no side-effects. |
786 | */ | 786 | */ |
787 | u64 current_tick_length(void) | 787 | u64 current_tick_length(long shift) |
788 | { | 788 | { |
789 | long delta_nsec; | 789 | long delta_nsec; |
790 | u64 ret; | ||
790 | 791 | ||
792 | /* calculate the finest interval NTP will allow. | ||
793 | * ie: nanosecond value shifted by (SHIFT_SCALE - 10) | ||
794 | */ | ||
791 | delta_nsec = tick_nsec + adjtime_adjustment() * 1000; | 795 | delta_nsec = tick_nsec + adjtime_adjustment() * 1000; |
792 | return ((u64) delta_nsec << (SHIFT_SCALE - 10)) + time_adj; | 796 | ret = ((u64) delta_nsec << (SHIFT_SCALE - 10)) + time_adj; |
797 | |||
798 | /* convert from (SHIFT_SCALE - 10) to specified shift scale: */ | ||
799 | shift = shift - (SHIFT_SCALE - 10); | ||
800 | if (shift < 0) | ||
801 | ret >>= -shift; | ||
802 | else | ||
803 | ret <<= shift; | ||
804 | |||
805 | return ret; | ||
793 | } | 806 | } |
794 | 807 | ||
795 | /* XXX - all of this timekeeping code should be later moved to time.c */ | 808 | /* XXX - all of this timekeeping code should be later moved to time.c */ |