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>
This commit is contained in:
parent
058892e632
commit
cc06268c6a
1 changed files with 17 additions and 22 deletions
|
@ -172,17 +172,26 @@ static inline s64 timekeeping_get_ns_raw(void)
|
||||||
return clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift);
|
return clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* must hold write on timekeeper.lock */
|
||||||
|
static void timekeeping_update(bool clearntp)
|
||||||
|
{
|
||||||
|
if (clearntp) {
|
||||||
|
timekeeper.ntp_error = 0;
|
||||||
|
ntp_clear();
|
||||||
|
}
|
||||||
|
update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
|
||||||
|
timekeeper.clock, timekeeper.mult);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void timekeeping_leap_insert(int leapsecond)
|
void timekeeping_leap_insert(int leapsecond)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
write_seqlock_irqsave(&timekeeper.lock, flags);
|
write_seqlock_irqsave(&timekeeper.lock, flags);
|
||||||
|
|
||||||
timekeeper.xtime.tv_sec += leapsecond;
|
timekeeper.xtime.tv_sec += leapsecond;
|
||||||
timekeeper.wall_to_monotonic.tv_sec -= leapsecond;
|
timekeeper.wall_to_monotonic.tv_sec -= leapsecond;
|
||||||
update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
|
timekeeping_update(false);
|
||||||
timekeeper.clock, timekeeper.mult);
|
|
||||||
|
|
||||||
write_sequnlock_irqrestore(&timekeeper.lock, flags);
|
write_sequnlock_irqrestore(&timekeeper.lock, flags);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -386,12 +395,7 @@ int do_settimeofday(const struct timespec *tv)
|
||||||
timespec_sub(timekeeper.wall_to_monotonic, ts_delta);
|
timespec_sub(timekeeper.wall_to_monotonic, ts_delta);
|
||||||
|
|
||||||
timekeeper.xtime = *tv;
|
timekeeper.xtime = *tv;
|
||||||
|
timekeeping_update(true);
|
||||||
timekeeper.ntp_error = 0;
|
|
||||||
ntp_clear();
|
|
||||||
|
|
||||||
update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
|
|
||||||
timekeeper.clock, timekeeper.mult);
|
|
||||||
|
|
||||||
write_sequnlock_irqrestore(&timekeeper.lock, flags);
|
write_sequnlock_irqrestore(&timekeeper.lock, flags);
|
||||||
|
|
||||||
|
@ -425,11 +429,7 @@ int timekeeping_inject_offset(struct timespec *ts)
|
||||||
timekeeper.wall_to_monotonic =
|
timekeeper.wall_to_monotonic =
|
||||||
timespec_sub(timekeeper.wall_to_monotonic, *ts);
|
timespec_sub(timekeeper.wall_to_monotonic, *ts);
|
||||||
|
|
||||||
timekeeper.ntp_error = 0;
|
timekeeping_update(true);
|
||||||
ntp_clear();
|
|
||||||
|
|
||||||
update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
|
|
||||||
timekeeper.clock, timekeeper.mult);
|
|
||||||
|
|
||||||
write_sequnlock_irqrestore(&timekeeper.lock, flags);
|
write_sequnlock_irqrestore(&timekeeper.lock, flags);
|
||||||
|
|
||||||
|
@ -668,10 +668,7 @@ void timekeeping_inject_sleeptime(struct timespec *delta)
|
||||||
|
|
||||||
__timekeeping_inject_sleeptime(delta);
|
__timekeeping_inject_sleeptime(delta);
|
||||||
|
|
||||||
timekeeper.ntp_error = 0;
|
timekeeping_update(true);
|
||||||
ntp_clear();
|
|
||||||
update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
|
|
||||||
timekeeper.clock, timekeeper.mult);
|
|
||||||
|
|
||||||
write_sequnlock_irqrestore(&timekeeper.lock, flags);
|
write_sequnlock_irqrestore(&timekeeper.lock, flags);
|
||||||
|
|
||||||
|
@ -1083,9 +1080,7 @@ static void update_wall_time(void)
|
||||||
second_overflow();
|
second_overflow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check to see if there is a new clocksource to use */
|
timekeeping_update(false);
|
||||||
update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
|
|
||||||
timekeeper.clock, timekeeper.mult);
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
write_sequnlock_irqrestore(&timekeeper.lock, flags);
|
write_sequnlock_irqrestore(&timekeeper.lock, flags);
|
||||||
|
|
Reference in a new issue