aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/main.h
diff options
context:
space:
mode:
authorMartin Hundebøll <martin@hundeboll.net>2011-12-08 07:32:41 -0500
committerMarek Lindner <lindner_marek@yahoo.de>2012-02-16 13:50:19 -0500
commita04ccd5970ec11f0b320971051435d86d3233c92 (patch)
treea57eaf54189eea3f63a30ee89a9be4e19513342e /net/batman-adv/main.h
parentc51f9c09fabc96f23e449b5e39b1fc4e2cabcd85 (diff)
batman-adv: Move is_out_of_time() to main.h for general use
Both translation tables and network coding use timeouts to do house keeping, so we might as well share the function used to compare a timestamp+timeout with current time. For readability and simplicity, the function is renamed to has_timed_out() and uses time_is_before_jiffies() instead of time_after(). Signed-off-by: Martin Hundebøll <martin@hundeboll.net> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv/main.h')
-rw-r--r--net/batman-adv/main.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 86354e06eb48..f9c659b3f3a9 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -202,6 +202,17 @@ static inline int compare_eth(const void *data1, const void *data2)
202 return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); 202 return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
203} 203}
204 204
205/**
206 * has_timed_out - compares current time (jiffies) and timestamp + timeout
207 * @timestamp: base value to compare with (in jiffies)
208 * @timeout: added to base value before comparing (in milliseconds)
209 *
210 * Returns true if current time is after timestamp + timeout
211 */
212static inline bool has_timed_out(unsigned long timestamp, unsigned int timeout)
213{
214 return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout));
215}
205 216
206#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0) 217#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)
207 218