diff options
-rw-r--r-- | include/linux/time.h | 2 | ||||
-rw-r--r-- | kernel/posix-timers.c | 10 |
2 files changed, 4 insertions, 8 deletions
diff --git a/include/linux/time.h b/include/linux/time.h index 8e83f4e778bb..bfbe92d0767c 100644 --- a/include/linux/time.h +++ b/include/linux/time.h | |||
@@ -101,7 +101,7 @@ extern struct timespec timespec_trunc(struct timespec t, unsigned gran); | |||
101 | static inline void | 101 | static inline void |
102 | set_normalized_timespec (struct timespec *ts, time_t sec, long nsec) | 102 | set_normalized_timespec (struct timespec *ts, time_t sec, long nsec) |
103 | { | 103 | { |
104 | while (nsec > NSEC_PER_SEC) { | 104 | while (nsec >= NSEC_PER_SEC) { |
105 | nsec -= NSEC_PER_SEC; | 105 | nsec -= NSEC_PER_SEC; |
106 | ++sec; | 106 | ++sec; |
107 | } | 107 | } |
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index ea55c7a1cd75..5870efb3e200 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c | |||
@@ -270,7 +270,7 @@ static void tstojiffie(struct timespec *tp, int res, u64 *jiff) | |||
270 | long sec = tp->tv_sec; | 270 | long sec = tp->tv_sec; |
271 | long nsec = tp->tv_nsec + res - 1; | 271 | long nsec = tp->tv_nsec + res - 1; |
272 | 272 | ||
273 | if (nsec > NSEC_PER_SEC) { | 273 | if (nsec >= NSEC_PER_SEC) { |
274 | sec++; | 274 | sec++; |
275 | nsec -= NSEC_PER_SEC; | 275 | nsec -= NSEC_PER_SEC; |
276 | } | 276 | } |
@@ -1209,13 +1209,9 @@ static int do_posix_clock_monotonic_get(clockid_t clock, struct timespec *tp) | |||
1209 | 1209 | ||
1210 | do_posix_clock_monotonic_gettime_parts(tp, &wall_to_mono); | 1210 | do_posix_clock_monotonic_gettime_parts(tp, &wall_to_mono); |
1211 | 1211 | ||
1212 | tp->tv_sec += wall_to_mono.tv_sec; | 1212 | set_normalized_timespec(tp, tp->tv_sec + wall_to_mono.tv_sec, |
1213 | tp->tv_nsec += wall_to_mono.tv_nsec; | 1213 | tp->tv_nsec + wall_to_mono.tv_nsec); |
1214 | 1214 | ||
1215 | if ((tp->tv_nsec - NSEC_PER_SEC) > 0) { | ||
1216 | tp->tv_nsec -= NSEC_PER_SEC; | ||
1217 | tp->tv_sec++; | ||
1218 | } | ||
1219 | return 0; | 1215 | return 0; |
1220 | } | 1216 | } |
1221 | 1217 | ||