All of lore.kernel.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH] batman-adv: restructure cfg80211 compat code
@ 2017-01-24  0:00 Linus Lüssing
  2017-01-24 12:46 ` Sven Eckelmann
  0 siblings, 1 reply; 2+ messages in thread
From: Linus Lüssing @ 2017-01-24  0:00 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Antonio Quartulli

This commit restructures the compat code regarding cfg80211 to achieve
the following:

a) Allows to compile kernels < 3.16 with -Werror by replacing the
"#warning" with a runtime warning through pr_warn_once().
b) Allows to run < 3.16 kernels without warnings if no cfg80211 based
interface is used.
c) Migrates cfg80211 compat code from compat.h to compat cfg80211.h to
keep compat.h slim.

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
---
 compat-include/net/cfg80211.h | 21 ++++++++++++++++++++-
 compat.h                      | 21 ---------------------
 2 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/compat-include/net/cfg80211.h b/compat-include/net/cfg80211.h
index 8dbbf0e..6e0eca3 100644
--- a/compat-include/net/cfg80211.h
+++ b/compat-include/net/cfg80211.h
@@ -4,9 +4,28 @@
 #include <linux/version.h>
 #include_next <net/cfg80211.h>
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)
+
+static inline int cfg80211_get_station(struct net_device *dev,
+				       const u8 *mac_addr,
+				       struct station_info *sinfo)
+{
+	pr_warn_once("cfg80211 based throughput metric is only supported with Linux 3.16+\n");
+	return -ENOENT;
+}
+
+/* The following define substitutes the expected_throughput field with a random
+ * one existing in the station_info struct. It can be random because due to the
+ * function above it will never be used. Only needed to make the code compile
+ */
+#define expected_throughput filled
+
+#endif /* < KERNEL_VERSION(3, 16, 0) */
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
 
-#if !IS_ENABLED(CONFIG_CFG80211)
+#if !IS_ENABLED(CONFIG_CFG80211) && \
+    LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
 
 #define cfg80211_get_station(dev, mac_addr, sinfo) \
 	batadv_cfg80211_get_station(dev, mac_addr, sinfo)
diff --git a/compat.h b/compat.h
index 5397629..e43c413 100644
--- a/compat.h
+++ b/compat.h
@@ -130,27 +130,6 @@ static int __batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\
 
 #endif /* < KERNEL_VERSION(3, 10, 0) */
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)
-
-/* the expected behaviour of this function is to return 0 on success, therefore
- * it is possible to define it as 1 so that batman-adv thinks like something
- * went wrong. It will then decide what to do.
- */
-#define cfg80211_get_station(_a, _b, _c) (1)
-/* the following define substitute the expected_throughput field with a random
- * one existing in the station_info struct. It can be random because due to the
- * define above it will never be used. We need it only to make the code compile
- */
-#define expected_throughput filled
-
-#ifdef CONFIG_BATMAN_ADV_BATMAN_V
-
-#warning cfg80211 based throughput metric is only supported with Linux 3.15+
-
-#endif
-
-#endif /* < KERNEL_VERSION(3, 16, 0) */
-
 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
 
 /* wild hack for batadv_getlink_net only */
-- 
2.1.4


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

* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: restructure cfg80211 compat code
  2017-01-24  0:00 [B.A.T.M.A.N.] [PATCH] batman-adv: restructure cfg80211 compat code Linus Lüssing
@ 2017-01-24 12:46 ` Sven Eckelmann
  0 siblings, 0 replies; 2+ messages in thread
From: Sven Eckelmann @ 2017-01-24 12:46 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Antonio Quartulli

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

On Dienstag, 24. Januar 2017 01:00:30 CET Linus Lüssing wrote:
> This commit restructures the compat code regarding cfg80211 to achieve
> the following:
> 
> a) Allows to compile kernels < 3.16 with -Werror by replacing the
> "#warning" with a runtime warning through pr_warn_once().
> b) Allows to run < 3.16 kernels without warnings if no cfg80211 based
> interface is used.
> c) Migrates cfg80211 compat code from compat.h to compat cfg80211.h to
> keep compat.h slim.
> 
> Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
> ---
>  compat-include/net/cfg80211.h | 21 ++++++++++++++++++++-
>  compat.h                      | 21 ---------------------
>  2 files changed, 20 insertions(+), 22 deletions(-)

Applied in 3da7de5d6aa8f69d6d7daa62f3e6d3f7ebed5772 [1]

Thanks,
	Sven

[1] https://git.open-mesh.org/batman-adv.git/commit/3da7de5d6aa8f69d6d7daa62f3e6d3f7ebed5772


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

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

end of thread, other threads:[~2017-01-24 12:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-24  0:00 [B.A.T.M.A.N.] [PATCH] batman-adv: restructure cfg80211 compat code Linus Lüssing
2017-01-24 12:46 ` Sven Eckelmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.