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 <zippel@linux-m68k.org>
---
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 & 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 & 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 >...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? --
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 --
| Andrew Morton | Re: Linux 2.6.21-rc4 |
| Andrew Morton | echo mem > /sys/power/state |
| Adrian Bunk | Re: 2.6.23-rc9 boot failure (megaraid?) |
| Florian Schmidt | blacklist kernel boot option |
git: | |
| Nicolas Pitre | Re: [PATCH] gc: call "prune --expire 2.weeks.ago" |
| Linus Torvalds | Re: git versus CVS (versus bk) |
| Ping Yin | [RFC] git reset --recover |
| Russ Dill | git-svn+cygwin failed fetch |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
| Karel Kulhavy | lookup option in /etc/resolv.conf ignored |
| Alexey Suslikov | OT: OpenBSD on Asus eeePC |
| ACP | maybe OT 3 year anniversay of Chuck Yerkes death |
| David Miller | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Karsten Keil | Linux IPv6 DAD not full conform to RFC 4862 ? |
| Arkadiusz Miskiewicz | htb and UDP packages bigger than 1500 |
| Ilpo Järvinen | Re: [PATCH] INET : removes per bucket rwlock in tcp/dccp ehash table |
