netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: netdev@vger.kernel.org
Cc: Johannes Berg <johannes.berg@intel.com>
Subject: [RFC 2/7] hsr: use genl_register_family_with_ops()
Date: Thu, 14 Nov 2013 10:14:41 +0100	[thread overview]
Message-ID: <1384420486-8713-3-git-send-email-johannes@sipsolutions.net> (raw)
In-Reply-To: <1384420486-8713-1-git-send-email-johannes@sipsolutions.net>

From: Johannes Berg <johannes.berg@intel.com>

This simplifies the code since there's no longer a
need to have error handling in the registration.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/hsr/hsr_netlink.c | 46 +++++++++++++++++-----------------------------
 1 file changed, 17 insertions(+), 29 deletions(-)

diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c
index 4e66bf6..8f52a9f 100644
--- a/net/hsr/hsr_netlink.c
+++ b/net/hsr/hsr_netlink.c
@@ -306,15 +306,6 @@ fail:
 	return res;
 }
 
-static struct genl_ops hsr_ops_get_node_status = {
-	.cmd = HSR_C_GET_NODE_STATUS,
-	.flags = 0,
-	.policy = hsr_genl_policy,
-	.doit = hsr_get_node_status,
-	.dumpit = NULL,
-};
-
-
 /* Get a list of MacAddressA of all nodes known to this node (other than self).
  */
 static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
@@ -398,12 +389,21 @@ fail:
 }
 
 
-static struct genl_ops hsr_ops_get_node_list = {
-	.cmd = HSR_C_GET_NODE_LIST,
-	.flags = 0,
-	.policy = hsr_genl_policy,
-	.doit = hsr_get_node_list,
-	.dumpit = NULL,
+static struct genl_ops hsr_ops[] = {
+	{
+		.cmd = HSR_C_GET_NODE_STATUS,
+		.flags = 0,
+		.policy = hsr_genl_policy,
+		.doit = hsr_get_node_status,
+		.dumpit = NULL,
+	},
+	{
+		.cmd = HSR_C_GET_NODE_LIST,
+		.flags = 0,
+		.policy = hsr_genl_policy,
+		.doit = hsr_get_node_list,
+		.dumpit = NULL,
+	},
 };
 
 int __init hsr_netlink_init(void)
@@ -414,18 +414,11 @@ int __init hsr_netlink_init(void)
 	if (rc)
 		goto fail_rtnl_link_register;
 
-	rc = genl_register_family(&hsr_genl_family);
+	rc = genl_register_family_with_ops(&hsr_genl_family, hsr_ops,
+					   ARRAY_SIZE(hsr_ops));
 	if (rc)
 		goto fail_genl_register_family;
 
-	rc = genl_register_ops(&hsr_genl_family, &hsr_ops_get_node_status);
-	if (rc)
-		goto fail_genl_register_ops;
-
-	rc = genl_register_ops(&hsr_genl_family, &hsr_ops_get_node_list);
-	if (rc)
-		goto fail_genl_register_ops_node_list;
-
 	rc = genl_register_mc_group(&hsr_genl_family, &hsr_network_genl_mcgrp);
 	if (rc)
 		goto fail_genl_register_mc_group;
@@ -433,10 +426,6 @@ int __init hsr_netlink_init(void)
 	return 0;
 
 fail_genl_register_mc_group:
-	genl_unregister_ops(&hsr_genl_family, &hsr_ops_get_node_list);
-fail_genl_register_ops_node_list:
-	genl_unregister_ops(&hsr_genl_family, &hsr_ops_get_node_status);
-fail_genl_register_ops:
 	genl_unregister_family(&hsr_genl_family);
 fail_genl_register_family:
 	rtnl_link_unregister(&hsr_link_ops);
@@ -448,7 +437,6 @@ fail_rtnl_link_register:
 void __exit hsr_netlink_exit(void)
 {
 	genl_unregister_mc_group(&hsr_genl_family, &hsr_network_genl_mcgrp);
-	genl_unregister_ops(&hsr_genl_family, &hsr_ops_get_node_status);
 	genl_unregister_family(&hsr_genl_family);
 
 	rtnl_link_unregister(&hsr_link_ops);
-- 
1.8.4.rc3

  parent reply	other threads:[~2013-11-14  9:14 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-14  9:14 [RFC 0/7] genetlink: reduce ops size and complexity Johannes Berg
2013-11-14  9:14 ` [RFC 1/7] taskstats: use genl_register_family_with_ops() Johannes Berg
2013-11-14  9:14 ` Johannes Berg [this message]
2013-11-14  9:14 ` [RFC 3/7] ieee802154: " Johannes Berg
2013-11-14  9:14 ` [RFC 4/7] wimax: " Johannes Berg
2013-11-14  9:14 ` [RFC 5/7] genetlink: remove genl_register_ops/genl_unregister_ops Johannes Berg
2013-11-14  9:14 ` [RFC 6/7] genetlink: register family ops as array Johannes Berg
2013-11-14  9:14 ` [RFC 7/7] genetlink: allow making ops const Johannes Berg
2013-11-14 13:41 ` [RFC 8/7] genetlink: make all genl_ops users const Johannes Berg
2013-11-14 14:01 ` [RFC 9/7] genetlink: make genl_ops flags a u8 and move to end Johannes Berg
2013-11-14 14:36 ` [RFC 0/7] genetlink: reduce ops size and complexity Johannes Berg
2013-11-14 16:02 ` Johannes Berg
2013-11-14 16:14 ` [PATCH 0/9] genetlink: reduce ops size and complexity (v2) Johannes Berg
2013-11-14 16:14   ` [PATCH 1/9] taskstats: use genl_register_family_with_ops() Johannes Berg
2013-11-14 16:14   ` [PATCH 2/9] hsr: " Johannes Berg
2013-11-14 16:14   ` [PATCH 3/9] ieee802154: " Johannes Berg
2013-11-14 16:14   ` [PATCH 4/9] wimax: " Johannes Berg
2013-11-14 16:14   ` [PATCH 5/9] genetlink: remove genl_register_ops/genl_unregister_ops Johannes Berg
2013-11-14 16:14   ` [PATCH 6/9] genetlink: register family ops as array Johannes Berg
2013-11-14 16:14   ` [PATCH 7/9] genetlink: allow making ops const Johannes Berg
2013-11-14 16:14   ` [PATCH 8/9] genetlink: make all genl_ops users const Johannes Berg
2013-11-14 16:14   ` [PATCH 9/9] genetlink: make genl_ops flags a u8 and move to end Johannes Berg
2013-11-14 22:12   ` [PATCH 0/9] genetlink: reduce ops size and complexity (v2) David Miller
2013-11-15 13:18     ` Johannes Berg
2013-11-15 13:23       ` Johannes Berg
2013-11-15 14:45         ` Jamal Hadi Salim
2013-11-16  1:54         ` David Miller
2013-11-16  1:53       ` David Miller
2013-11-17  9:12         ` Johannes Berg

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=1384420486-8713-3-git-send-email-johannes@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=johannes.berg@intel.com \
    --cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).