Skip to content

Commit

Permalink
hsr: use genl_register_family_with_ops()
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
jmberg-intel authored and davem330 committed Nov 14, 2013
1 parent 88d36a9 commit 9504b3e
Showing 1 changed file with 17 additions and 29 deletions.
46 changes: 17 additions & 29 deletions net/hsr/hsr_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,6 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info)
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)
Expand Down Expand Up @@ -398,12 +389,21 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
}


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)
Expand All @@ -414,29 +414,18 @@ 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;

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);
Expand All @@ -448,7 +437,6 @@ int __init hsr_netlink_init(void)
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);
Expand Down

0 comments on commit 9504b3e

Please sign in to comment.