From 1c582d915da13ca21ad375ae04ec1bd6193418b2 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 14 Nov 2013 17:14:41 +0100 Subject: ieee802154: use genl_register_family_with_ops() This simplifies the code since there's no longer a need to have error handling in the registration. Unfortunately it means more extern function declarations are needed, but the overall goal would seem to justify this. While at it, also fix the registration error path - if the family registration failed then it shouldn't be unregistered. Signed-off-by: Johannes Berg Signed-off-by: David S. Miller --- net/ieee802154/netlink.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'net/ieee802154/netlink.c') diff --git a/net/ieee802154/netlink.c b/net/ieee802154/netlink.c index 7e49bbcc6967..eb9faef6782a 100644 --- a/net/ieee802154/netlink.c +++ b/net/ieee802154/netlink.c @@ -109,24 +109,39 @@ out: return -ENOBUFS; } +static struct genl_ops ieee8021154_ops[] = { + /* see nl-phy.c */ + IEEE802154_DUMP(IEEE802154_LIST_PHY, ieee802154_list_phy, + ieee802154_dump_phy), + IEEE802154_OP(IEEE802154_ADD_IFACE, ieee802154_add_iface), + IEEE802154_OP(IEEE802154_DEL_IFACE, ieee802154_del_iface), + /* see nl-mac.c */ + IEEE802154_OP(IEEE802154_ASSOCIATE_REQ, ieee802154_associate_req), + IEEE802154_OP(IEEE802154_ASSOCIATE_RESP, ieee802154_associate_resp), + IEEE802154_OP(IEEE802154_DISASSOCIATE_REQ, ieee802154_disassociate_req), + IEEE802154_OP(IEEE802154_SCAN_REQ, ieee802154_scan_req), + IEEE802154_OP(IEEE802154_START_REQ, ieee802154_start_req), + IEEE802154_DUMP(IEEE802154_LIST_IFACE, ieee802154_list_iface, + ieee802154_dump_iface), +}; + int __init ieee802154_nl_init(void) { int rc; - rc = genl_register_family(&nl802154_family); + rc = genl_register_family_with_ops(&nl802154_family, ieee8021154_ops, + ARRAY_SIZE(ieee8021154_ops)); if (rc) - goto fail; + return rc; - rc = nl802154_mac_register(); + rc = genl_register_mc_group(&nl802154_family, &ieee802154_coord_mcgrp); if (rc) goto fail; - rc = nl802154_phy_register(); + rc = genl_register_mc_group(&nl802154_family, &ieee802154_beacon_mcgrp); if (rc) goto fail; - return 0; - fail: genl_unregister_family(&nl802154_family); return rc; @@ -136,4 +151,3 @@ void __exit ieee802154_nl_exit(void) { genl_unregister_family(&nl802154_family); } - -- cgit v1.2.3