public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH] batman-adv: Move is_out_of_time() to main.c for general use
@ 2011-12-02 14:15 Martin Hundebøll
  2011-12-02 14:37 ` Martin Hundebøll
  2011-12-02 14:39 ` [B.A.T.M.A.N.] [PATCH] batman-adv: Rm trailing whitespace from is_my_mac() in main.c Martin Hundebøll
  0 siblings, 2 replies; 13+ messages in thread
From: Martin Hundebøll @ 2011-12-02 14:15 UTC (permalink / raw)
  To: b.a.t.m.a.n

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.

Also, this patch removes a trailing newline in is_my_mac() to satisfy checkpatch

Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
---
 main.c              |    4 ++++
 main.h              |    1 +
 translation-table.c |    8 --------
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/main.c b/main.c
index fb87bdc..0930bb4 100644
--- a/main.c
+++ b/main.c
@@ -170,7 +170,11 @@ int is_my_mac(const uint8_t *addr)
 	}
 	rcu_read_unlock();
 	return 0;
+}
 
+bool is_out_of_time(unsigned long timestamp, unsigned long timeout)
+{
+	return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout));
 }
 
 module_init(batman_init);
diff --git a/main.h b/main.h
index 464439f..92eb37b 100644
--- a/main.h
+++ b/main.h
@@ -159,6 +159,7 @@ void mesh_free(struct net_device *soft_iface);
 void inc_module_count(void);
 void dec_module_count(void);
 int is_my_mac(const uint8_t *addr);
+bool is_out_of_time(unsigned long timestamp, unsigned long timeout);
 
 #ifdef CONFIG_BATMAN_ADV_DEBUG
 int debug_log(struct bat_priv *bat_priv, const char *fmt, ...) __printf(2, 3);
diff --git a/translation-table.c b/translation-table.c
index 7a7df4a..b22f8d9 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -108,14 +108,6 @@ static struct tt_global_entry *tt_global_hash_find(struct bat_priv *bat_priv,
 
 }
 
-static bool is_out_of_time(unsigned long starting_time, unsigned long timeout)
-{
-	unsigned long deadline;
-	deadline = starting_time + msecs_to_jiffies(timeout);
-
-	return time_after(jiffies, deadline);
-}
-
 static void tt_local_entry_free_ref(struct tt_local_entry *tt_local_entry)
 {
 	if (atomic_dec_and_test(&tt_local_entry->common.refcount))
-- 
1.7.7.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-12-10  9:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-02 14:15 [B.A.T.M.A.N.] [PATCH] batman-adv: Move is_out_of_time() to main.c for general use Martin Hundebøll
2011-12-02 14:37 ` Martin Hundebøll
2011-12-03  7:36   ` Marek Lindner
2011-12-03 15:41     ` Martin Hundebøll
2011-12-03 15:46       ` Marek Lindner
2011-12-03 15:54         ` Martin Hundebøll
2011-12-08 12:32           ` [B.A.T.M.A.N.] [PATCHv2] batman-adv: Move is_out_of_time() to main.h " Martin Hundebøll
2011-12-10  9:28             ` Marek Lindner
2011-12-02 14:39 ` [B.A.T.M.A.N.] [PATCH] batman-adv: Rm trailing whitespace from is_my_mac() in main.c Martin Hundebøll
2011-12-03  7:27   ` Marek Lindner
2011-12-03 15:39     ` Martin Hundebøll
2011-12-08 11:48       ` [B.A.T.M.A.N.] [PATCHv2] batman-adv: Rm empty line " Martin Hundebøll
2011-12-10  9:18         ` Marek Lindner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox