On Saturday 21 May 2016 20:16:14 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(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.
net/batman-adv/bat_v.c | 14 ++++++++++++++
net/batman-adv/bat_v.h | 5 +++++
net/batman-adv/hard-interface.c | 10 ++--------
3 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
index e4a91cd..81157a3 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -334,6 +334,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
This seems to be the first use of atomic functions in this file. Can you
please add "#include <linux/atomic.h>" to have the atomic_set functions
defined.
And yes, it is a lot nicer than my quick fix :)
Thanks,
Sven