lkml.org 
[lkml]   [2005]   [Aug]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[RFC][PATCH - 12/13] NTP cleanup: cleanup ntp_advance() adjtime code
From
Date
All,
This patch simplifies and cleans up the adjtime code in ntp_advance and
corrects a comment.

Any comments or feedback would be greatly appreciated.

thanks
-john

linux-2.6.13-rc6_timeofday-ntp-part12_B5.patch
============================================
diff --git a/kernel/ntp.c b/kernel/ntp.c
--- a/kernel/ntp.c
+++ b/kernel/ntp.c
@@ -156,29 +156,25 @@ void ntp_advance(unsigned long interval_
shifted_ppm_sum += ss_adj << SHIFT_USEC;


- if ( (time_adjust_step = ntp_adjtime_offset) != 0 ) {
- /* We are doing an adjtime thing.
- *
- * Prepare time_adjust_step to be within bounds.
- * Note that a positive ntp_adjtime_offset means we want the clock
- * to run faster.
- *
- * Limit the amount of the step to be in the range
- * -tickadj .. +tickadj
- */
- if (ntp_adjtime_offset > tickadj)
- time_adjust_step = tickadj;
- else if (ntp_adjtime_offset < -tickadj)
- time_adjust_step = -tickadj;
+ /* Calculate the fixed tick adjustment */
+ fixed_tick_ns_adj = 0;

- /* Reduce by this step the amount of time left */
- ntp_adjtime_offset -= time_adjust_step;
+ /* If we are doing an adjtime thing */
+ if (ntp_adjtime_offset) {
+ long adjust_step = ntp_adjtime_offset;
+ /* Limit the amount of the step to be in the range
+ * -tickadj .. +tickadj
+ */
+ adjust_step = min_t(long, tickadj, adjust_step);
+ adjust_step = max_t(long, -tickadj, adjust_step);
+ /* Reduce by this step the amount of time left */
+ ntp_adjtime_offset -= adjust_step;
+ fixed_tick_ns_adj += adjust_step * 1000;
}
- fixed_tick_ns_adj = time_adjust_step * 1000;

/*
- * Advance the phase, once it gets to one microsecond, then
- * advance the tick more.
+ * Advance the phase, once it gets to one nanosecond,
+ * then advance the fixed_tick_ns_adj.
*/
time_phase += time_adj;
if (time_phase <= -FINENSEC) {

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-08-11 03:39    [W:0.439 / U:0.340 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site