diff options
-rw-r--r-- | include/linux/time.h | 16 | ||||
-rw-r--r-- | kernel/time/timekeeping.c | 6 |
2 files changed, 19 insertions, 3 deletions
diff --git a/include/linux/time.h b/include/linux/time.h index ea3559f0b3f2..9072df83de1f 100644 --- a/include/linux/time.h +++ b/include/linux/time.h | |||
@@ -76,9 +76,25 @@ extern unsigned long mktime(const unsigned int year, const unsigned int mon, | |||
76 | const unsigned int min, const unsigned int sec); | 76 | const unsigned int min, const unsigned int sec); |
77 | 77 | ||
78 | extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec); | 78 | extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec); |
79 | |||
80 | /* | ||
81 | * timespec_add_safe assumes both values are positive and checks | ||
82 | * for overflow. It will return TIME_T_MAX if the reutrn would be | ||
83 | * smaller then either of the arguments. | ||
84 | */ | ||
79 | extern struct timespec timespec_add_safe(const struct timespec lhs, | 85 | extern struct timespec timespec_add_safe(const struct timespec lhs, |
80 | const struct timespec rhs); | 86 | const struct timespec rhs); |
81 | 87 | ||
88 | |||
89 | static inline struct timespec timespec_add(struct timespec lhs, | ||
90 | struct timespec rhs) | ||
91 | { | ||
92 | struct timespec ts_delta; | ||
93 | set_normalized_timespec(&ts_delta, lhs.tv_sec + rhs.tv_sec, | ||
94 | lhs.tv_nsec + rhs.tv_nsec); | ||
95 | return ts_delta; | ||
96 | } | ||
97 | |||
82 | /* | 98 | /* |
83 | * sub = lhs - rhs, in normalized form | 99 | * sub = lhs - rhs, in normalized form |
84 | */ | 100 | */ |
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index caf8d4d4f5c8..623fe3d504dc 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -579,9 +579,9 @@ static int timekeeping_resume(struct sys_device *dev) | |||
579 | 579 | ||
580 | if (timespec_compare(&ts, &timekeeping_suspend_time) > 0) { | 580 | if (timespec_compare(&ts, &timekeeping_suspend_time) > 0) { |
581 | ts = timespec_sub(ts, timekeeping_suspend_time); | 581 | ts = timespec_sub(ts, timekeeping_suspend_time); |
582 | xtime = timespec_add_safe(xtime, ts); | 582 | xtime = timespec_add(xtime, ts); |
583 | wall_to_monotonic = timespec_sub(wall_to_monotonic, ts); | 583 | wall_to_monotonic = timespec_sub(wall_to_monotonic, ts); |
584 | total_sleep_time = timespec_add_safe(total_sleep_time, ts); | 584 | total_sleep_time = timespec_add(total_sleep_time, ts); |
585 | } | 585 | } |
586 | /* re-base the last cycle value */ | 586 | /* re-base the last cycle value */ |
587 | timekeeper.clock->cycle_last = timekeeper.clock->read(timekeeper.clock); | 587 | timekeeper.clock->cycle_last = timekeeper.clock->read(timekeeper.clock); |
@@ -887,7 +887,7 @@ EXPORT_SYMBOL_GPL(getboottime); | |||
887 | */ | 887 | */ |
888 | void monotonic_to_bootbased(struct timespec *ts) | 888 | void monotonic_to_bootbased(struct timespec *ts) |
889 | { | 889 | { |
890 | *ts = timespec_add_safe(*ts, total_sleep_time); | 890 | *ts = timespec_add(*ts, total_sleep_time); |
891 | } | 891 | } |
892 | EXPORT_SYMBOL_GPL(monotonic_to_bootbased); | 892 | EXPORT_SYMBOL_GPL(monotonic_to_bootbased); |
893 | 893 | ||