summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-02-22 12:57:49 +0100
committerIngo Molnar <mingo@elte.hu>2009-02-25 18:38:11 +0100
commitf939890b6687e05c42361655fb6610fa08f5a601 (patch)
tree9d01f8c51bd2fe883c407a36bf034b412181c483 /kernel
parentbc26c31d446bc9c24cd6f7003777a05fe268ae48 (diff)
downloadblackbird-op-linux-f939890b6687e05c42361655fb6610fa08f5a601.tar.gz
blackbird-op-linux-f939890b6687e05c42361655fb6610fa08f5a601.zip
time: ntp: refactor and clean up ntp_update_offset()
Impact: cleanup, no functionality changed - introduce the ntp_update_offset_fll() helper - clean up the flow and variable naming kernel/time/ntp.o: text data bss dec hex filename 2504 114 136 2754 ac2 ntp.o.before 2504 114 136 2754 ac2 ntp.o.after md5: 01f7b8e1a5472a3056f9e4ae84d46315 ntp.o.before.asm 01f7b8e1a5472a3056f9e4ae84d46315 ntp.o.after.asm Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/time/ntp.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index f1abad738579..ee437e1445d1 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -103,10 +103,27 @@ static void ntp_update_frequency(void)
tick_length_base = new_base;
}
+static inline s64 ntp_update_offset_fll(s64 freq_adj, s64 offset64, long secs)
+{
+ time_status &= ~STA_MODE;
+
+ if (secs < MINSEC)
+ return freq_adj;
+
+ if (!(time_status & STA_FLL) && (secs <= MAXSEC))
+ return freq_adj;
+
+ freq_adj += div_s64(offset64 << (NTP_SCALE_SHIFT - SHIFT_FLL), secs);
+ time_status |= STA_MODE;
+
+ return freq_adj;
+}
+
static void ntp_update_offset(long offset)
{
- long mtemp;
s64 freq_adj;
+ s64 offset64;
+ long secs;
if (!(time_status & STA_PLL))
return;
@@ -127,22 +144,21 @@ static void ntp_update_offset(long offset)
*/
if (time_status & STA_FREQHOLD || time_reftime == 0)
time_reftime = xtime.tv_sec;
- mtemp = xtime.tv_sec - time_reftime;
+
+ secs = xtime.tv_sec - time_reftime;
time_reftime = xtime.tv_sec;
- freq_adj = (s64)offset * mtemp;
- freq_adj <<= NTP_SCALE_SHIFT - 2 * (SHIFT_PLL + 2 + time_constant);
- time_status &= ~STA_MODE;
- if (mtemp >= MINSEC && (time_status & STA_FLL || mtemp > MAXSEC)) {
- freq_adj += div_s64((s64)offset << (NTP_SCALE_SHIFT - SHIFT_FLL),
- mtemp);
- time_status |= STA_MODE;
- }
- freq_adj += time_freq;
- freq_adj = min(freq_adj, MAXFREQ_SCALED);
- time_freq = max(freq_adj, -MAXFREQ_SCALED);
+ offset64 = offset;
+ freq_adj = (offset64 * secs) <<
+ (NTP_SCALE_SHIFT - 2 * (SHIFT_PLL + 2 + time_constant));
+
+ freq_adj = ntp_update_offset_fll(freq_adj, offset64, secs);
+
+ freq_adj = min(freq_adj + time_freq, MAXFREQ_SCALED);
+
+ time_freq = max(freq_adj, -MAXFREQ_SCALED);
- time_offset = div_s64((s64)offset << NTP_SCALE_SHIFT, NTP_INTERVAL_FREQ);
+ time_offset = div_s64(offset64 << NTP_SCALE_SHIFT, NTP_INTERVAL_FREQ);
}
/**
OpenPOWER on IntegriCloud