login
Header Space

 
 

[PATCH 1/8] cleanup ntp.c

Previous thread: [PATCH 4/8] increase time_offset resolution by zippel on Friday, March 14, 2008 - 2:40 pm. (1 message)

Next thread: [PATCH 2/8] NTP4 user space bits update by zippel on Friday, March 14, 2008 - 2:40 pm. (3 messages)
To: <linux-kernel@...>
Cc: <akpm@...>, <johnstul@...>
Date: Friday, March 14, 2008 - 2:40 pm

This is mostly a style cleanup of ntp.c and extracts part of do_adjtimex
as ntp_update_offset(). Otherwise the functionality is still the same as
before.

Signed-off-by: Roman Zippel &lt;zippel@linux-m68k.org&gt;

---
 kernel/time/ntp.c |  171 ++++++++++++++++++++++++++++--------------------------
 1 file changed, 90 insertions(+), 81 deletions(-)

Index: linux-2.6-mm/kernel/time/ntp.c
===================================================================
--- linux-2.6-mm.orig/kernel/time/ntp.c
+++ linux-2.6-mm/kernel/time/ntp.c
@@ -35,7 +35,7 @@ static u64 tick_length, tick_length_base
 /* TIME_ERROR prevents overwriting the CMOS clock */
 static int time_state = TIME_OK;	/* clock synchronization status	*/
 int time_status = STA_UNSYNC;		/* clock status bits		*/
-static s64 time_offset;		/* time adjustment (ns)		*/
+static s64 time_offset;			/* time adjustment (ns)		*/
 static long time_constant = 2;		/* pll time constant		*/
 long time_maxerror = NTP_PHASE_LIMIT;	/* maximum error (us)		*/
 long time_esterror = NTP_PHASE_LIMIT;	/* estimated error (us)		*/
@@ -57,6 +57,44 @@ static void ntp_update_frequency(void)
 	tick_length_base = div_u64(tick_length_base, NTP_INTERVAL_FREQ);
 }
 
+static void ntp_update_offset(long offset)
+{
+	long mtemp;
+	s64 freq_adj;
+
+	if (!(time_status &amp; STA_PLL))
+		return;
+
+	time_offset = offset * NSEC_PER_USEC;
+
+	/*
+	 * Scale the phase adjustment and
+	 * clamp to the operating range.
+	 */
+	time_offset = min(time_offset, (s64)MAXPHASE * NSEC_PER_USEC);
+	time_offset = max(time_offset, (s64)-MAXPHASE * NSEC_PER_USEC);
+
+	/*
+	 * Select how the frequency is to be controlled
+	 * and in which mode (PLL or FLL).
+	 */
+	if (time_status &amp; STA_FREQHOLD || time_reftime == 0)
+		time_reftime = xtime.tv_sec;
+	mtemp = xtime.tv_sec - time_reftime;
+	time_reftime = xtime.tv_sec;
+
+	freq_adj = time_offset * mtemp;
+	freq_adj = shift_right(freq_adj, time_constant * 2 +
+			   (SHIFT_PLL + 2) * 2 - SHIFT_NSEC);
+	if (mtemp &gt...
To: <zippel@...>
Cc: <linux-kernel@...>, <akpm@...>, Ingo Molnar <mingo@...>
Date: Friday, March 14, 2008 - 4:30 pm

Ah crud. Ingo sent very similar changes to me a few weeks ago, and I've
been too pinched for time to test and send them out. 

I'll spend some time today to layer his fixes as well as my own cleanups
on top. 

Minor nits below:

Otherwise looks good (although I've not tested it).


Could we change this to a more descriptive name?


--
To: john stultz <johnstul@...>
Cc: <linux-kernel@...>, <akpm@...>, Ingo Molnar <mingo@...>
Date: Friday, March 14, 2008 - 11:21 pm

Hi,



It's a local variable, so IMO temp works just fine, it's not that 
difficult to figure out how it's used (e.g. it's like using loop_index 
instead of i).

bye, Roman
--
Previous thread: [PATCH 4/8] increase time_offset resolution by zippel on Friday, March 14, 2008 - 2:40 pm. (1 message)

Next thread: [PATCH 2/8] NTP4 user space bits update by zippel on Friday, March 14, 2008 - 2:40 pm. (3 messages)
speck-geostationary