Skip to content

Commit

Permalink
ntp: Introduce and use SECS_PER_DAY macro instead of 86400
Browse files Browse the repository at this point in the history
Currently the leapsecond logic uses what looks like magic values.

Improve this by defining SECS_PER_DAY and using that macro
to make the logic more clear.

Signed-off-by: John Stultz <john.stultz@linaro.org>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jiri Bohac <jbohac@suse.cz>
Cc: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1434063297-28657-3-git-send-email-john.stultz@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
John Stultz authored and Thomas Gleixner committed Jun 12, 2015
1 parent d151832 commit 90bf361
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kernel/time/ntp.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ unsigned long tick_nsec;
static u64 tick_length;
static u64 tick_length_base;

#define SECS_PER_DAY 86400
#define MAX_TICKADJ 500LL /* usecs */
#define MAX_TICKADJ_SCALED \
(((MAX_TICKADJ * NSEC_PER_USEC) << NTP_SCALE_SHIFT) / NTP_INTERVAL_FREQ)
Expand Down Expand Up @@ -390,7 +391,7 @@ int second_overflow(unsigned long secs)
case TIME_INS:
if (!(time_status & STA_INS))
time_state = TIME_OK;
else if (secs % 86400 == 0) {
else if (secs % SECS_PER_DAY == 0) {
leap = -1;
time_state = TIME_OOP;
printk(KERN_NOTICE
Expand All @@ -400,7 +401,7 @@ int second_overflow(unsigned long secs)
case TIME_DEL:
if (!(time_status & STA_DEL))
time_state = TIME_OK;
else if ((secs + 1) % 86400 == 0) {
else if ((secs + 1) % SECS_PER_DAY == 0) {
leap = 1;
time_state = TIME_WAIT;
printk(KERN_NOTICE
Expand Down

0 comments on commit 90bf361

Please sign in to comment.