Skip to content

Commit

Permalink
timekeeping: Pass flags instead of multiple bools to timekeeping_upda…
Browse files Browse the repository at this point in the history
…te()

Instead of passing multiple bools to timekeeping_updated(), define
flags and use a single 'action' parameter.  It is then more obvious
what each timekeeping_update() call does.

Signed-off-by: David Vrabel <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: John Stultz <[email protected]>
Cc: <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Thomas Gleixner <[email protected]>
  • Loading branch information
David Vrabel authored and KAGA-KOKO committed Jun 28, 2013
1 parent 0eb0716 commit 04397fe
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#include "ntp_internal.h"
#include "timekeeping_internal.h"

#define TK_CLEAR_NTP (1 << 0)
#define TK_MIRROR (1 << 1)

static struct timekeeper timekeeper;
static DEFINE_RAW_SPINLOCK(timekeeper_lock);
static seqcount_t timekeeper_seq;
Expand Down Expand Up @@ -242,16 +245,16 @@ int pvclock_gtod_unregister_notifier(struct notifier_block *nb)
EXPORT_SYMBOL_GPL(pvclock_gtod_unregister_notifier);

/* must hold timekeeper_lock */
static void timekeeping_update(struct timekeeper *tk, bool clearntp, bool mirror)
static void timekeeping_update(struct timekeeper *tk, unsigned int action)
{
if (clearntp) {
if (action & TK_CLEAR_NTP) {
tk->ntp_error = 0;
ntp_clear();
}
update_vsyscall(tk);
update_pvclock_gtod(tk);

if (mirror)
if (action & TK_MIRROR)
memcpy(&shadow_timekeeper, &timekeeper, sizeof(timekeeper));
}

Expand Down Expand Up @@ -509,7 +512,7 @@ int do_settimeofday(const struct timespec *tv)

tk_set_xtime(tk, tv);

timekeeping_update(tk, true, true);
timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR);

write_seqcount_end(&timekeeper_seq);
raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
Expand Down Expand Up @@ -553,7 +556,7 @@ int timekeeping_inject_offset(struct timespec *ts)
tk_set_wall_to_mono(tk, timespec_sub(tk->wall_to_monotonic, *ts));

error: /* even if we error out, we forwarded the time, so call update */
timekeeping_update(tk, true, true);
timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR);

write_seqcount_end(&timekeeper_seq);
raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
Expand Down Expand Up @@ -643,7 +646,7 @@ static int change_clocksource(void *data)
module_put(new->owner);
}
}
timekeeping_update(tk, true, true);
timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR);

write_seqcount_end(&timekeeper_seq);
raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
Expand Down Expand Up @@ -884,7 +887,7 @@ void timekeeping_inject_sleeptime(struct timespec *delta)

__timekeeping_inject_sleeptime(tk, delta);

timekeeping_update(tk, true, true);
timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR);

write_seqcount_end(&timekeeper_seq);
raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
Expand Down Expand Up @@ -966,7 +969,7 @@ static void timekeeping_resume(void)
tk->cycle_last = clock->cycle_last = cycle_now;
tk->ntp_error = 0;
timekeeping_suspended = 0;
timekeeping_update(tk, false, true);
timekeeping_update(tk, TK_MIRROR);
write_seqcount_end(&timekeeper_seq);
raw_spin_unlock_irqrestore(&timekeeper_lock, flags);

Expand Down Expand Up @@ -1419,7 +1422,7 @@ static void update_wall_time(void)
* updating.
*/
memcpy(real_tk, tk, sizeof(*tk));
timekeeping_update(real_tk, false, false);
timekeeping_update(real_tk, 0);
write_seqcount_end(&timekeeper_seq);
out:
raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
Expand Down

0 comments on commit 04397fe

Please sign in to comment.