diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-02-22 09:48:43 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-02-25 12:38:15 -0500 |
commit | 2b9d1496e7835a603c340e8f0dd81f4b74d5f248 (patch) | |
tree | 419904a23470733179a0ecd647263777b2f8e780 | |
parent | e96291653b2e4df02f160b574070f6e632868e5e (diff) |
time: ntp: make 64-bit constants more robust
Impact: cleanup, no functionality changed
- make PPM_SCALE an explicit s64 constant, to
remove (s64) casts from usage sites.
kernel/time/ntp.o:
text data bss dec hex filename
2536 114 136 2786 ae2 ntp.o.before
2536 114 136 2786 ae2 ntp.o.after
md5:
40a7728d1188aa18e83e21a81fa7b150 ntp.o.before.asm
40a7728d1188aa18e83e21a81fa7b150 ntp.o.after.asm
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | include/linux/timex.h | 2 | ||||
-rw-r--r-- | kernel/time/ntp.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/include/linux/timex.h b/include/linux/timex.h index 998a55d80acf..aa3475fcff64 100644 --- a/include/linux/timex.h +++ b/include/linux/timex.h | |||
@@ -190,7 +190,7 @@ struct timex { | |||
190 | * offset and maximum frequency tolerance. | 190 | * offset and maximum frequency tolerance. |
191 | */ | 191 | */ |
192 | #define SHIFT_USEC 16 /* frequency offset scale (shift) */ | 192 | #define SHIFT_USEC 16 /* frequency offset scale (shift) */ |
193 | #define PPM_SCALE (NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC)) | 193 | #define PPM_SCALE ((s64)NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC)) |
194 | #define PPM_SCALE_INV_SHIFT 19 | 194 | #define PPM_SCALE_INV_SHIFT 19 |
195 | #define PPM_SCALE_INV ((1ll << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \ | 195 | #define PPM_SCALE_INV ((1ll << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \ |
196 | PPM_SCALE + 1) | 196 | PPM_SCALE + 1) |
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 4346ed6e623f..7447d57e021a 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c | |||
@@ -408,7 +408,7 @@ static inline void process_adjtimex_modes(struct timex *txc, struct timespec *ts | |||
408 | time_status &= ~STA_NANO; | 408 | time_status &= ~STA_NANO; |
409 | 409 | ||
410 | if (txc->modes & ADJ_FREQUENCY) { | 410 | if (txc->modes & ADJ_FREQUENCY) { |
411 | time_freq = (s64)txc->freq * PPM_SCALE; | 411 | time_freq = txc->freq * PPM_SCALE; |
412 | time_freq = min(time_freq, MAXFREQ_SCALED); | 412 | time_freq = min(time_freq, MAXFREQ_SCALED); |
413 | time_freq = max(time_freq, -MAXFREQ_SCALED); | 413 | time_freq = max(time_freq, -MAXFREQ_SCALED); |
414 | } | 414 | } |
@@ -505,7 +505,7 @@ int do_adjtimex(struct timex *txc) | |||
505 | result = TIME_ERROR; | 505 | result = TIME_ERROR; |
506 | 506 | ||
507 | txc->freq = shift_right((time_freq >> PPM_SCALE_INV_SHIFT) * | 507 | txc->freq = shift_right((time_freq >> PPM_SCALE_INV_SHIFT) * |
508 | (s64)PPM_SCALE_INV, NTP_SCALE_SHIFT); | 508 | PPM_SCALE_INV, NTP_SCALE_SHIFT); |
509 | txc->maxerror = time_maxerror; | 509 | txc->maxerror = time_maxerror; |
510 | txc->esterror = time_esterror; | 510 | txc->esterror = time_esterror; |
511 | txc->status = time_status; | 511 | txc->status = time_status; |