aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2011-11-13 18:19:49 -0500
committerJohn Stultz <john.stultz@linaro.org>2012-01-26 22:44:31 -0500
commitcc06268c6a87db156af2daed6e96a936b955cc82 (patch)
tree7edfb767cf3a58b82c8ee299d3689943b87d1d3d /kernel/time
parent058892e632aa53be8255c2f0a42f9ace7bed66bb (diff)
time: Move common updates to a function
CC: Thomas Gleixner <tglx@linutronix.de> CC: Eric Dumazet <eric.dumazet@gmail.com> CC: Richard Cochran <richardcochran@gmail.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/timekeeping.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 06f40ae13b7b..403c2a092830 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -172,17 +172,26 @@ static inline s64 timekeeping_get_ns_raw(void)
172 return clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift); 172 return clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift);
173} 173}
174 174
175/* must hold write on timekeeper.lock */
176static void timekeeping_update(bool clearntp)
177{
178 if (clearntp) {
179 timekeeper.ntp_error = 0;
180 ntp_clear();
181 }
182 update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
183 timekeeper.clock, timekeeper.mult);
184}
185
186
175void timekeeping_leap_insert(int leapsecond) 187void timekeeping_leap_insert(int leapsecond)
176{ 188{
177 unsigned long flags; 189 unsigned long flags;
178 190
179 write_seqlock_irqsave(&timekeeper.lock, flags); 191 write_seqlock_irqsave(&timekeeper.lock, flags);
180
181 timekeeper.xtime.tv_sec += leapsecond; 192 timekeeper.xtime.tv_sec += leapsecond;
182 timekeeper.wall_to_monotonic.tv_sec -= leapsecond; 193 timekeeper.wall_to_monotonic.tv_sec -= leapsecond;
183 update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic, 194 timekeeping_update(false);
184 timekeeper.clock, timekeeper.mult);
185
186 write_sequnlock_irqrestore(&timekeeper.lock, flags); 195 write_sequnlock_irqrestore(&timekeeper.lock, flags);
187 196
188} 197}
@@ -386,12 +395,7 @@ int do_settimeofday(const struct timespec *tv)
386 timespec_sub(timekeeper.wall_to_monotonic, ts_delta); 395 timespec_sub(timekeeper.wall_to_monotonic, ts_delta);
387 396
388 timekeeper.xtime = *tv; 397 timekeeper.xtime = *tv;
389 398 timekeeping_update(true);
390 timekeeper.ntp_error = 0;
391 ntp_clear();
392
393 update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
394 timekeeper.clock, timekeeper.mult);
395 399
396 write_sequnlock_irqrestore(&timekeeper.lock, flags); 400 write_sequnlock_irqrestore(&timekeeper.lock, flags);
397 401
@@ -425,11 +429,7 @@ int timekeeping_inject_offset(struct timespec *ts)
425 timekeeper.wall_to_monotonic = 429 timekeeper.wall_to_monotonic =
426 timespec_sub(timekeeper.wall_to_monotonic, *ts); 430 timespec_sub(timekeeper.wall_to_monotonic, *ts);
427 431
428 timekeeper.ntp_error = 0; 432 timekeeping_update(true);
429 ntp_clear();
430
431 update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
432 timekeeper.clock, timekeeper.mult);
433 433
434 write_sequnlock_irqrestore(&timekeeper.lock, flags); 434 write_sequnlock_irqrestore(&timekeeper.lock, flags);
435 435
@@ -668,10 +668,7 @@ void timekeeping_inject_sleeptime(struct timespec *delta)
668 668
669 __timekeeping_inject_sleeptime(delta); 669 __timekeeping_inject_sleeptime(delta);
670 670
671 timekeeper.ntp_error = 0; 671 timekeeping_update(true);
672 ntp_clear();
673 update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
674 timekeeper.clock, timekeeper.mult);
675 672
676 write_sequnlock_irqrestore(&timekeeper.lock, flags); 673 write_sequnlock_irqrestore(&timekeeper.lock, flags);
677 674
@@ -1083,9 +1080,7 @@ static void update_wall_time(void)
1083 second_overflow(); 1080 second_overflow();
1084 } 1081 }
1085 1082
1086 /* check to see if there is a new clocksource to use */ 1083 timekeeping_update(false);
1087 update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
1088 timekeeper.clock, timekeeper.mult);
1089 1084
1090out: 1085out:
1091 write_sequnlock_irqrestore(&timekeeper.lock, flags); 1086 write_sequnlock_irqrestore(&timekeeper.lock, flags);