diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2014-06-11 18:19:28 +0200 |
---|---|---|
committer | Alex Shi <alex.shi@linaro.org> | 2015-01-27 11:12:32 +0800 |
commit | 2b6cbae40fb12a884caf2771b0da40a0b0ef3ad0 (patch) | |
tree | 352b303cb717dc8760c1a0163d1f1da0cd6bfcf1 | |
parent | 2f26c30ebd9dab895dfa64a046a645c7e5183e1e (diff) |
ktime: add ktime_after and ktime_before helperDaniel-cpuidle
Add two minimal helper functions analogous to time_before() and
time_after() that will later on both be needed by SCTP code.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 67cb9366ff5f99868100198efba5ca88aaa6ad25)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
Conflicts:
net/sctp/sm_make_chunk.c
(cherry picked from commit 3c1cdfbe30f5502cbbb864c52b3408e857a32e5d)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
-rw-r--r-- | include/linux/ktime.h | 24 | ||||
-rw-r--r-- | net/sctp/sm_make_chunk.c | 2 |
2 files changed, 25 insertions, 1 deletions
diff --git a/include/linux/ktime.h b/include/linux/ktime.h index bbca12804d1..fdb75543c7b 100644 --- a/include/linux/ktime.h +++ b/include/linux/ktime.h @@ -301,6 +301,30 @@ static inline int ktime_compare(const ktime_t cmp1, const ktime_t cmp2) return 0; } +/** + * ktime_after - Compare if a ktime_t value is bigger than another one. + * @cmp1: comparable1 + * @cmp2: comparable2 + * + * Return: true if cmp1 happened after cmp2. + */ +static inline bool ktime_after(const ktime_t cmp1, const ktime_t cmp2) +{ + return ktime_compare(cmp1, cmp2) > 0; +} + +/** + * ktime_before - Compare if a ktime_t value is smaller than another one. + * @cmp1: comparable1 + * @cmp2: comparable2 + * + * Return: true if cmp1 happened before cmp2. + */ +static inline bool ktime_before(const ktime_t cmp1, const ktime_t cmp2) +{ + return ktime_compare(cmp1, cmp2) < 0; +} + static inline s64 ktime_to_us(const ktime_t kt) { struct timeval tv = ktime_to_timeval(kt); diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 87e244be899..5f94d72a941 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c @@ -1764,7 +1764,7 @@ no_hmac: else do_gettimeofday(&tv); - if (!asoc && tv_lt(bear_cookie->expiration, tv)) { + if (!asoc && ktime_before(bear_cookie->expiration, kt)) { /* * Section 3.3.10.3 Stale Cookie Error (3) * |