b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH v4] batman-adv: B.A.T.M.A.N. V - implement hard-iface init function
@ 2016-05-21 13:35 Antonio Quartulli
  2016-05-21 14:30 ` Sven Eckelmann
  0 siblings, 1 reply; 3+ messages in thread
From: Antonio Quartulli @ 2016-05-21 13:35 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Antonio Quartulli

Some fields in the hard-interface data structure are specific to the
B.A.T.M.A.N. V protocol and have to be initialized only when such
protocol is compiled in.
Instead of having a #ifdef block in the middle of the hard-interface.c
code it is better to have an algorithm private function that hides the
precompiler logic in its own header file (like other functions).

Fixes: ffd2f27908e5 ("batman-adv: Only init ELP tweaking options when BATMAN_V is enabled")
Signed-off-by: Antonio Quartulli <a@unstable.cc>
---

Changes from v1:
- move bat_algo.h include line to the right location

Changes from v2:
- rebased on top of newest master to fix compile error.

Changes from v3:
- add missing "#include <linux/atomic.h>"


 net/batman-adv/bat_v.c          | 15 +++++++++++++++
 net/batman-adv/bat_v.h          |  5 +++++
 net/batman-adv/hard-interface.c | 10 ++--------
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
index e4a91cd..7231440 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -18,6 +18,7 @@
 #include "bat_v.h"
 #include "main.h"
 
+#include <linux/atomic.h>
 #include <linux/bug.h>
 #include <linux/cache.h>
 #include <linux/init.h>
@@ -334,6 +335,20 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {
 };
 
 /**
+ * batadv_v_hardif_init - initialize the algorithm specific fields in the
+ *  hard-interface object
+ * @hard_iface: the hard-interface to initialize
+ */
+void batadv_v_hardif_init(struct batadv_hard_iface *hard_iface)
+{
+	/* enable link throughput auto-detection by setting the throughput
+	 * override to zero
+	 */
+	atomic_set(&hard_iface->bat_v.throughput_override, 0);
+	atomic_set(&hard_iface->bat_v.elp_interval, 500);
+}
+
+/**
  * batadv_v_mesh_init - initialize the B.A.T.M.A.N. V private resources for a
  *  mesh
  * @bat_priv: the object representing the mesh interface to initialise
diff --git a/net/batman-adv/bat_v.h b/net/batman-adv/bat_v.h
index 52dd6cf..83b7763 100644
--- a/net/batman-adv/bat_v.h
+++ b/net/batman-adv/bat_v.h
@@ -23,6 +23,7 @@
 #ifdef CONFIG_BATMAN_ADV_BATMAN_V
 
 int batadv_v_init(void);
+void batadv_v_hardif_init(struct batadv_hard_iface *hardif);
 int batadv_v_mesh_init(struct batadv_priv *bat_priv);
 void batadv_v_mesh_free(struct batadv_priv *bat_priv);
 
@@ -33,6 +34,10 @@ static inline int batadv_v_init(void)
 	return 0;
 }
 
+static inline void batadv_v_hardif_init(struct batadv_hard_iface *hardif)
+{
+}
+
 static inline int batadv_v_mesh_init(struct batadv_priv *bat_priv)
 {
 	return 0;
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 6689656..70841c1 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -37,6 +37,7 @@
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
 
+#include "bat_v.h"
 #include "bridge_loop_avoidance.h"
 #include "debugfs.h"
 #include "distributed-arp-table.h"
@@ -684,14 +685,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
 	if (batadv_is_wifi_netdev(net_dev))
 		hard_iface->num_bcasts = BATADV_NUM_BCASTS_WIRELESS;
 
-#ifdef CONFIG_BATMAN_ADV_BATMAN_V
-	/* enable link throughput auto-detection by setting the throughput
-	 * override to zero
-	 */
-	atomic_set(&hard_iface->bat_v.throughput_override, 0);
-
-	atomic_set(&hard_iface->bat_v.elp_interval, 500);
-#endif
+	batadv_v_hardif_init(hard_iface);
 
 	/* extra reference for return */
 	kref_init(&hard_iface->refcount);
-- 
2.8.3


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

* Re: [B.A.T.M.A.N.] [PATCH v4] batman-adv: B.A.T.M.A.N. V - implement hard-iface init function
  2016-05-21 13:35 [B.A.T.M.A.N.] [PATCH v4] batman-adv: B.A.T.M.A.N. V - implement hard-iface init function Antonio Quartulli
@ 2016-05-21 14:30 ` Sven Eckelmann
  2016-06-07  2:06   ` Marek Lindner
  0 siblings, 1 reply; 3+ messages in thread
From: Sven Eckelmann @ 2016-05-21 14:30 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Antonio Quartulli

[-- Attachment #1: Type: text/plain, Size: 661 bytes --]

On Saturday 21 May 2016 21:35:55 Antonio Quartulli wrote:
> Some fields in the hard-interface data structure are specific to the
> B.A.T.M.A.N. V protocol and have to be initialized only when such
> protocol is compiled in.
> Instead of having a #ifdef block in the middle of the hard-interface.c
> code it is better to have an algorithm private function that hides the
> precompiler logic in its own header file (like other functions).
> 
> Fixes: ffd2f27908e5 ("batman-adv: Only init ELP tweaking options when
> BATMAN_V is enabled") Signed-off-by: Antonio Quartulli <a@unstable.cc>
> ---

Reviewed-by: Sven Eckelmann <sven@narfation.org>

Kind regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [B.A.T.M.A.N.] [PATCH v4] batman-adv: B.A.T.M.A.N. V - implement hard-iface init function
  2016-05-21 14:30 ` Sven Eckelmann
@ 2016-06-07  2:06   ` Marek Lindner
  0 siblings, 0 replies; 3+ messages in thread
From: Marek Lindner @ 2016-06-07  2:06 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Antonio Quartulli

[-- Attachment #1: Type: text/plain, Size: 768 bytes --]

On Saturday, May 21, 2016 16:30:53 Sven Eckelmann wrote:
> On Saturday 21 May 2016 21:35:55 Antonio Quartulli wrote:
> > Some fields in the hard-interface data structure are specific to the
> > B.A.T.M.A.N. V protocol and have to be initialized only when such
> > protocol is compiled in.
> > Instead of having a #ifdef block in the middle of the hard-interface.c
> > code it is better to have an algorithm private function that hides the
> > precompiler logic in its own header file (like other functions).
> >
> > Fixes: ffd2f27908e5 ("batman-adv: Only init ELP tweaking options when
> > BATMAN_V is enabled") Signed-off-by: Antonio Quartulli <a@unstable.cc>
> > ---
> 
> Reviewed-by: Sven Eckelmann <sven@narfation.org>

Applied in revision 713586f.

Thanks,
Marek

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

end of thread, other threads:[~2016-06-07  2:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-21 13:35 [B.A.T.M.A.N.] [PATCH v4] batman-adv: B.A.T.M.A.N. V - implement hard-iface init function Antonio Quartulli
2016-05-21 14:30 ` Sven Eckelmann
2016-06-07  2:06   ` Marek Lindner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).