diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index bca3667..81dc975 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1586,7 +1586,7 @@ static __always_inline void timekeeping_freqadjust(struct timekeeper *tk, s64 interval = tk->cycle_interval; s64 xinterval = tk->xtime_interval; s64 tick_error; - bool negative; + bool negative = 0; u32 adj; /* Remove any current error adj from freq calculation */ @@ -1604,10 +1604,12 @@ static __always_inline void timekeeping_freqadjust(struct timekeeper *tk, return; /* preserve the direction of correction */ - negative = (tick_error < 0); + if (tick_error < 0) { + tick_error = -tick_error; + negative = 1; + } /* Sort out the magnitude of the correction */ - tick_error = abs(tick_error); for (adj = 0; tick_error > interval; adj++) tick_error >>= 1;