From: Antonio Quartulli <a@unstable.cc>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Antonio Quartulli <a@unstable.cc>
Subject: [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: B.A.T.M.A.N. V - implement hard-iface init function
Date: Wed, 11 May 2016 18:29:17 +0800 [thread overview]
Message-ID: <1462962557-23950-2-git-send-email-a@unstable.cc> (raw)
In-Reply-To: <1462962557-23950-1-git-send-email-a@unstable.cc>
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>
---
net/batman-adv/bat_algo.h | 5 +++++
net/batman-adv/bat_v.c | 14 ++++++++++++++
net/batman-adv/hard-interface.c | 10 ++--------
3 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/net/batman-adv/bat_algo.h b/net/batman-adv/bat_algo.h
index b727762..3654296 100644
--- a/net/batman-adv/bat_algo.h
+++ b/net/batman-adv/bat_algo.h
@@ -25,6 +25,7 @@ int batadv_iv_init(void);
#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);
@@ -35,6 +36,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/bat_v.c b/net/batman-adv/bat_v.c
index b9c2850..fb2d29d 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -333,6 +333,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/hard-interface.c b/net/batman-adv/hard-interface.c
index a8cda76..a757229 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -15,6 +15,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "bat_algo.h"
#include "hard-interface.h"
#include "main.h"
@@ -683,14 +684,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.2
next prev parent reply other threads:[~2016-05-11 10:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-11 10:29 [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: remove forward declaration by including proper header Antonio Quartulli
2016-05-11 10:29 ` Antonio Quartulli [this message]
2016-05-11 13:11 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: B.A.T.M.A.N. V - implement hard-iface init function Sven Eckelmann
2016-05-11 21:14 ` Antonio Quartulli
2016-05-11 10:38 ` [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: remove forward declaration by including proper header Sven Eckelmann
2016-05-11 10:47 ` Antonio Quartulli
2016-05-11 12:24 ` Sven Eckelmann
2016-05-12 21:07 ` Antonio Quartulli
2016-05-12 22:45 ` Sven Eckelmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462962557-23950-2-git-send-email-a@unstable.cc \
--to=a@unstable.cc \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox