summaryrefslogtreecommitdiffstats
path: root/kernel/timer.c
diff options
context:
space:
mode:
authorjohn stultz <johnstul@us.ibm.com>2006-06-26 00:25:07 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-26 09:58:20 -0700
commit260a42309b31cbc54eb4b6b85649e412bcad053f (patch)
tree51efc7bb51075b0d25d0e8465d3c056e6a57fe16 /kernel/timer.c
parentad596171ed635c51a9eef829187af100cbf8dcf7 (diff)
downloadblackbird-op-linux-260a42309b31cbc54eb4b6b85649e412bcad053f.tar.gz
blackbird-op-linux-260a42309b31cbc54eb4b6b85649e412bcad053f.zip
[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/timer.c')
-rw-r--r--kernel/timer.c21
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)
* Return how long ticks are at the moment, that is, how much time
* update_wall_time_one_tick will add to xtime next time we call it
* (assuming no calls to do_adjtimex in the meantime).
- * The return value is in fixed-point nanoseconds with SHIFT_SCALE-10
- * bits to the right of the binary point.
+ * The return value is in fixed-point nanoseconds shifted by the
+ * specified number of bits to the right of the binary point.
* This function has no side-effects.
*/
-u64 current_tick_length(void)
+u64 current_tick_length(long shift)
{
long delta_nsec;
+ u64 ret;
+ /* calculate the finest interval NTP will allow.
+ * ie: nanosecond value shifted by (SHIFT_SCALE - 10)
+ */
delta_nsec = tick_nsec + adjtime_adjustment() * 1000;
- return ((u64) delta_nsec << (SHIFT_SCALE - 10)) + time_adj;
+ ret = ((u64) delta_nsec << (SHIFT_SCALE - 10)) + time_adj;
+
+ /* convert from (SHIFT_SCALE - 10) to specified shift scale: */
+ shift = shift - (SHIFT_SCALE - 10);
+ if (shift < 0)
+ ret >>= -shift;
+ else
+ ret <<= shift;
+
+ return ret;
}
/* XXX - all of this timekeeping code should be later moved to time.c */
OpenPOWER on IntegriCloud