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>
This commit is contained in:

committed by
Marek Lindner

parent
c51f9c09fa
commit
a04ccd5970
@@ -202,6 +202,17 @@ static inline int compare_eth(const void *data1, const void *data2)
|
||||
return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* has_timed_out - compares current time (jiffies) and timestamp + timeout
|
||||
* @timestamp: base value to compare with (in jiffies)
|
||||
* @timeout: added to base value before comparing (in milliseconds)
|
||||
*
|
||||
* Returns true if current time is after timestamp + timeout
|
||||
*/
|
||||
static inline bool has_timed_out(unsigned long timestamp, unsigned int timeout)
|
||||
{
|
||||
return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout));
|
||||
}
|
||||
|
||||
#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)
|
||||
|
||||
|
Reference in New Issue
Block a user