aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/linux/time.h2
-rw-r--r--kernel/posix-timers.c10
2 files changed, 4 insertions, 8 deletions
diff --git a/include/linux/time.h b/include/linux/time.h
index 8e83f4e778b..bfbe92d0767 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);
static inline void
set_normalized_timespec (struct timespec *ts, time_t sec, long nsec)
{
- while (nsec > NSEC_PER_SEC) {
+ while (nsec >= NSEC_PER_SEC) {
nsec -= NSEC_PER_SEC;
++sec;
}
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index ea55c7a1cd7..5870efb3e20 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)
long sec = tp->tv_sec;
long nsec = tp->tv_nsec + res - 1;
- if (nsec > NSEC_PER_SEC) {
+ if (nsec >= NSEC_PER_SEC) {
sec++;
nsec -= NSEC_PER_SEC;
}
@@ -1209,13 +1209,9 @@ static int do_posix_clock_monotonic_get(clockid_t clock, struct timespec *tp)
do_posix_clock_monotonic_gettime_parts(tp, &wall_to_mono);
- tp->tv_sec += wall_to_mono.tv_sec;
- tp->tv_nsec += wall_to_mono.tv_nsec;
+ set_normalized_timespec(tp, tp->tv_sec + wall_to_mono.tv_sec,
+ tp->tv_nsec + wall_to_mono.tv_nsec);
- if ((tp->tv_nsec - NSEC_PER_SEC) > 0) {
- tp->tv_nsec -= NSEC_PER_SEC;
- tp->tv_sec++;
- }
return 0;
}