batman-adv: compat: Substitute compat code for netlink constification

Message ID 20161018212125.32010-1-linus.luessing@c0d3.blue (mailing list archive)
State RFC, archived
Delegated to: Simon Wunderlich
Headers

Commit Message

Linus Lüssing Oct. 18, 2016, 9:21 p.m. UTC
  Substitutes the compat-patches approach for the netlink const changes to
the prefered way of using compat-includes.

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
---
 compat-include/net/genetlink.h | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
  

Comments

Linus Lüssing Oct. 18, 2016, 9:24 p.m. UTC | #1
On Tue, Oct 18, 2016 at 11:21:25PM +0200, Linus Lüssing wrote:
> Substitutes the compat-patches approach for the netlink const changes to
> the prefered way of using compat-includes.
> 
> Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
> ---

Actually, it isn't a substitution yet, the compat-patches thing is
still there.

Let me know what you think about this approach and if you like it
what I should do about the replacements.sh.
  
Sven Eckelmann Oct. 18, 2016, 9:28 p.m. UTC | #2
On Dienstag, 18. Oktober 2016 23:21:25 CEST Linus Lüssing wrote:
> Substitutes the compat-patches approach for the netlink const changes to
> the prefered way of using compat-includes.
> 
> Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
> ---
>  compat-include/net/genetlink.h | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/compat-include/net/genetlink.h b/compat-include/net/genetlink.h
> index 72a8991..b195b47 100644
> --- a/compat-include/net/genetlink.h
> +++ b/compat-include/net/genetlink.h
> @@ -28,6 +28,15 @@
>  
>  #include <linux/export.h>
>  
> +/* multicast groups */
> +enum __batadv_netlink_multicast_groups {
> +	__BATADV_NL_MCGRP_TPMETER,
> +};
> +
> +static struct genl_multicast_group __batadv_netlink_mcgrps[] = {
> +	[__BATADV_NL_MCGRP_TPMETER] = { .name = BATADV_NL_MCAST_GROUP_TPMETER },
> +};
> +

Doesn't seem to scale. Especially when we think about batadv_netlink_ops
which should also be const. It is currently not const because of the
Linux <= 3.13 workaround.

Kind regards,
	Sven
  

Patch

diff --git a/compat-include/net/genetlink.h b/compat-include/net/genetlink.h
index 72a8991..b195b47 100644
--- a/compat-include/net/genetlink.h
+++ b/compat-include/net/genetlink.h
@@ -28,6 +28,15 @@ 
 
 #include <linux/export.h>
 
+/* multicast groups */
+enum __batadv_netlink_multicast_groups {
+	__BATADV_NL_MCGRP_TPMETER,
+};
+
+static struct genl_multicast_group __batadv_netlink_mcgrps[] = {
+	[__BATADV_NL_MCGRP_TPMETER] = { .name = BATADV_NL_MCAST_GROUP_TPMETER },
+};
+
 struct batadv_genl_family {
 	/* data handled by the actual kernel */
 	struct genl_family family;
@@ -140,12 +149,14 @@  static inline int batadv_genl_register_family(struct genl_family *family)
 static inline int
 batadv_genl_register_family_with_ops_grps(struct genl_family *family,
 					  struct genl_ops *ops, size_t n_ops,
-					  struct genl_multicast_group *mcgrps,
+					  const struct genl_multicast_group *mcgrps,
 					  size_t n_mcgrps)
 {
+	BUILD_BUG_ON(ARRAY_SIZE(__batadv_netlink_mcgrps) != n_mcgrps);
+
 	family->ops = ops;
 	family->n_ops = n_ops;
-	family->mcgrps = mcgrps;
+	family->mcgrps = __batadv_netlink_mcgrps;
 	family->n_mcgrps = n_mcgrps;
 	family->module = THIS_MODULE;