Skip to content

Commit

Permalink
time: Move common updates to a function
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Thomas Gleixner authored and John Stultz committed Jan 27, 2012
1 parent 058892e commit cc06268
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,26 @@ static inline s64 timekeeping_get_ns_raw(void)
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)
{
unsigned long flags;

write_seqlock_irqsave(&timekeeper.lock, flags);

timekeeper.xtime.tv_sec += leapsecond;
timekeeper.wall_to_monotonic.tv_sec -= leapsecond;
update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
timekeeper.clock, timekeeper.mult);

timekeeping_update(false);
write_sequnlock_irqrestore(&timekeeper.lock, flags);

}
Expand Down Expand Up @@ -386,12 +395,7 @@ int do_settimeofday(const struct timespec *tv)
timespec_sub(timekeeper.wall_to_monotonic, ts_delta);

timekeeper.xtime = *tv;

timekeeper.ntp_error = 0;
ntp_clear();

update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
timekeeper.clock, timekeeper.mult);
timekeeping_update(true);

write_sequnlock_irqrestore(&timekeeper.lock, flags);

Expand Down Expand Up @@ -425,11 +429,7 @@ int timekeeping_inject_offset(struct timespec *ts)
timekeeper.wall_to_monotonic =
timespec_sub(timekeeper.wall_to_monotonic, *ts);

timekeeper.ntp_error = 0;
ntp_clear();

update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
timekeeper.clock, timekeeper.mult);
timekeeping_update(true);

write_sequnlock_irqrestore(&timekeeper.lock, flags);

Expand Down Expand Up @@ -668,10 +668,7 @@ void timekeeping_inject_sleeptime(struct timespec *delta)

__timekeeping_inject_sleeptime(delta);

timekeeper.ntp_error = 0;
ntp_clear();
update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
timekeeper.clock, timekeeper.mult);
timekeeping_update(true);

write_sequnlock_irqrestore(&timekeeper.lock, flags);

Expand Down Expand Up @@ -1083,9 +1080,7 @@ static void update_wall_time(void)
second_overflow();
}

/* check to see if there is a new clocksource to use */
update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
timekeeper.clock, timekeeper.mult);
timekeeping_update(false);

out:
write_sequnlock_irqrestore(&timekeeper.lock, flags);
Expand Down

0 comments on commit cc06268

Please sign in to comment.