Skip to content

Commit 04397fe

Browse files
David VrabelKAGA-KOKO
authored andcommitted
timekeeping: Pass flags instead of multiple bools to timekeeping_update()
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 <david.vrabel@citrix.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: John Stultz <john.stultz@linaro.org> Cc: <xen-devel@lists.xen.org> Link: http://lkml.kernel.org/r/1372329348-20841-3-git-send-email-david.vrabel@citrix.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 0eb0716 commit 04397fe

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

kernel/time/timekeeping.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#include "ntp_internal.h"
2828
#include "timekeeping_internal.h"
2929

30+
#define TK_CLEAR_NTP (1 << 0)
31+
#define TK_MIRROR (1 << 1)
32+
3033
static struct timekeeper timekeeper;
3134
static DEFINE_RAW_SPINLOCK(timekeeper_lock);
3235
static seqcount_t timekeeper_seq;
@@ -242,16 +245,16 @@ int pvclock_gtod_unregister_notifier(struct notifier_block *nb)
242245
EXPORT_SYMBOL_GPL(pvclock_gtod_unregister_notifier);
243246

244247
/* must hold timekeeper_lock */
245-
static void timekeeping_update(struct timekeeper *tk, bool clearntp, bool mirror)
248+
static void timekeeping_update(struct timekeeper *tk, unsigned int action)
246249
{
247-
if (clearntp) {
250+
if (action & TK_CLEAR_NTP) {
248251
tk->ntp_error = 0;
249252
ntp_clear();
250253
}
251254
update_vsyscall(tk);
252255
update_pvclock_gtod(tk);
253256

254-
if (mirror)
257+
if (action & TK_MIRROR)
255258
memcpy(&shadow_timekeeper, &timekeeper, sizeof(timekeeper));
256259
}
257260

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

510513
tk_set_xtime(tk, tv);
511514

512-
timekeeping_update(tk, true, true);
515+
timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR);
513516

514517
write_seqcount_end(&timekeeper_seq);
515518
raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
@@ -553,7 +556,7 @@ int timekeeping_inject_offset(struct timespec *ts)
553556
tk_set_wall_to_mono(tk, timespec_sub(tk->wall_to_monotonic, *ts));
554557

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

558561
write_seqcount_end(&timekeeper_seq);
559562
raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
@@ -643,7 +646,7 @@ static int change_clocksource(void *data)
643646
module_put(new->owner);
644647
}
645648
}
646-
timekeeping_update(tk, true, true);
649+
timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR);
647650

648651
write_seqcount_end(&timekeeper_seq);
649652
raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
@@ -884,7 +887,7 @@ void timekeeping_inject_sleeptime(struct timespec *delta)
884887

885888
__timekeeping_inject_sleeptime(tk, delta);
886889

887-
timekeeping_update(tk, true, true);
890+
timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR);
888891

889892
write_seqcount_end(&timekeeper_seq);
890893
raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
@@ -966,7 +969,7 @@ static void timekeeping_resume(void)
966969
tk->cycle_last = clock->cycle_last = cycle_now;
967970
tk->ntp_error = 0;
968971
timekeeping_suspended = 0;
969-
timekeeping_update(tk, false, true);
972+
timekeeping_update(tk, TK_MIRROR);
970973
write_seqcount_end(&timekeeper_seq);
971974
raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
972975

@@ -1419,7 +1422,7 @@ static void update_wall_time(void)
14191422
* updating.
14201423
*/
14211424
memcpy(real_tk, tk, sizeof(*tk));
1422-
timekeeping_update(real_tk, false, false);
1425+
timekeeping_update(real_tk, 0);
14231426
write_seqcount_end(&timekeeper_seq);
14241427
out:
14251428
raw_spin_unlock_irqrestore(&timekeeper_lock, flags);

0 commit comments

Comments
 (0)