From patchwork Sat Oct 29 08:03:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 16780 X-Patchwork-Delegate: sven@narfation.org Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id 6D948830FB; Sat, 29 Oct 2016 10:03:42 +0200 (CEST) Authentication-Results: open-mesh.org; dmarc=none header.from=narfation.org Authentication-Results: open-mesh.org; dkim=fail reason="verification failed; unprotected key" header.d=narfation.org header.i=@narfation.org header.b=rMUqF89/; dkim-adsp=fail (unprotected policy); dkim-atps=neutral Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2001:4d88:2000:7::2; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=pass header.from=narfation.org Received: from v3-1039.vlinux.de (narfation.org [IPv6:2001:4d88:2000:7::2]) by open-mesh.org (Postfix) with ESMTPS id C1F2C830FD for ; Sat, 29 Oct 2016 10:03:34 +0200 (CEST) Received: from sven-desktop.home.narfation.org (p200300C593CDC8FD0000000000002E17.dip0.t-ipconnect.de [IPv6:2003:c5:93cd:c8fd::2e17]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 2E89E1C8001 for ; Sat, 29 Oct 2016 10:03:34 +0200 (CEST) Authentication-Results: v3-1039.vlinux.de; dmarc=none header.from=narfation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1477728214; bh=PmoOctIBNUJM+l1loU5OBR8OM1yY+ISA9AhFIswp2qU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rMUqF89/szEes3nAKZVKBOA7lmeBLs6nBQMqO6TLDOG7zixNHV7CePdu49zgPhTqH eVNkS5TWifVa6LhWEB5uqSaMWNLyWEzLjm0fYnZ18ghgjS6oaVDcvRQjhlIMSSBwJL lEtfNlASYj7SrnXH/Bf5bDIkYJGZuNWwDUTgUceM= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Sat, 29 Oct 2016 10:03:27 +0200 Message-Id: <20161029080328.26584-2-sven@narfation.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161029080328.26584-1-sven@narfation.org> References: <20161029080328.26584-1-sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: genetlink: statically initialize families X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" From: Johannes Berg Instead of providing macros/inline functions to initialize the families, make all users initialize them statically and get rid of the macros. This reduces the kernel code size by about 1.6k on x86-64 (with allyesconfig). Signed-off-by: Johannes Berg Signed-off-by: David S. Miller [sven@narfation.org: adjust compat code] Signed-off-by: Sven Eckelmann --- Patch already in net-next compat-include/net/genetlink.h | 21 ++------------------- net/batman-adv/netlink.c | 25 +++++++++++++++---------- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/compat-include/net/genetlink.h b/compat-include/net/genetlink.h index 6a287e6..b057e6c 100644 --- a/compat-include/net/genetlink.h +++ b/compat-include/net/genetlink.h @@ -96,11 +96,6 @@ batadv_genlmsg_multicast_netns(struct batadv_genl_family *family, #define genl_unregister_family(_family) \ genl_unregister_family(&(_family)->family) -#define genl_register_family_with_ops_groups(family, ops, grps) \ - batadv_genl_register_family_with_ops_grps((family), \ - (ops), ARRAY_SIZE(ops), \ - (grps), ARRAY_SIZE(grps)) - static inline int batadv_genl_register_family(struct genl_family *family) { unsigned int i; @@ -148,20 +143,8 @@ static inline int batadv_genl_register_family(struct genl_family *family) return ret; } -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, - size_t n_mcgrps) -{ - family->ops = ops; - family->n_ops = n_ops; - family->mcgrps = mcgrps; - family->n_mcgrps = n_mcgrps; - family->module = THIS_MODULE; - - return batadv_genl_register_family(family); -} +#define genl_register_family(family) \ + batadv_genl_register_family((family)) #define __genl_const diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c index a951e02..5dfc5c4 100644 --- a/net/batman-adv/netlink.c +++ b/net/batman-adv/netlink.c @@ -48,13 +48,7 @@ #include "tp_meter.h" #include "translation-table.h" -struct genl_family batadv_netlink_family = { - .hdrsize = 0, - .name = BATADV_NL_NAME, - .version = 1, - .maxattr = BATADV_ATTR_MAX, - .netnsok = true, -}; +struct genl_family batadv_netlink_family; /* multicast groups */ enum batadv_netlink_multicast_groups { @@ -609,6 +603,19 @@ static const struct genl_ops batadv_netlink_ops[] = { }; +struct genl_family batadv_netlink_family = { + .hdrsize = 0, + .name = BATADV_NL_NAME, + .version = 1, + .maxattr = BATADV_ATTR_MAX, + .netnsok = true, + .module = THIS_MODULE, + .ops = batadv_netlink_ops, + .n_ops = ARRAY_SIZE(batadv_netlink_ops), + .mcgrps = batadv_netlink_mcgrps, + .n_mcgrps = ARRAY_SIZE(batadv_netlink_mcgrps), +}; + /** * batadv_netlink_register - register batadv genl netlink family */ @@ -616,9 +623,7 @@ void __init batadv_netlink_register(void) { int ret; - ret = genl_register_family_with_ops_groups(&batadv_netlink_family, - batadv_netlink_ops, - batadv_netlink_mcgrps); + ret = genl_register_family(&batadv_netlink_family); if (ret) pr_warn("unable to register netlink family"); }