taskstats: use genl_register_family_with_ops()
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>
This commit is contained in:
committed by
David S. Miller
parent
1e9f3d6f1c
commit
88d36a9949
@@ -673,17 +673,18 @@ err:
|
|||||||
nlmsg_free(rep_skb);
|
nlmsg_free(rep_skb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct genl_ops taskstats_ops = {
|
static struct genl_ops taskstats_ops[] = {
|
||||||
|
{
|
||||||
.cmd = TASKSTATS_CMD_GET,
|
.cmd = TASKSTATS_CMD_GET,
|
||||||
.doit = taskstats_user_cmd,
|
.doit = taskstats_user_cmd,
|
||||||
.policy = taskstats_cmd_get_policy,
|
.policy = taskstats_cmd_get_policy,
|
||||||
.flags = GENL_ADMIN_PERM,
|
.flags = GENL_ADMIN_PERM,
|
||||||
};
|
},
|
||||||
|
{
|
||||||
static struct genl_ops cgroupstats_ops = {
|
|
||||||
.cmd = CGROUPSTATS_CMD_GET,
|
.cmd = CGROUPSTATS_CMD_GET,
|
||||||
.doit = cgroupstats_user_cmd,
|
.doit = cgroupstats_user_cmd,
|
||||||
.policy = cgroupstats_cmd_get_policy,
|
.policy = cgroupstats_cmd_get_policy,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Needed early in initialization */
|
/* Needed early in initialization */
|
||||||
@@ -702,26 +703,14 @@ static int __init taskstats_init(void)
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = genl_register_family(&family);
|
rc = genl_register_family_with_ops(&family, taskstats_ops,
|
||||||
|
ARRAY_SIZE(taskstats_ops));
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
rc = genl_register_ops(&family, &taskstats_ops);
|
|
||||||
if (rc < 0)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
rc = genl_register_ops(&family, &cgroupstats_ops);
|
|
||||||
if (rc < 0)
|
|
||||||
goto err_cgroup_ops;
|
|
||||||
|
|
||||||
family_registered = 1;
|
family_registered = 1;
|
||||||
pr_info("registered taskstats version %d\n", TASKSTATS_GENL_VERSION);
|
pr_info("registered taskstats version %d\n", TASKSTATS_GENL_VERSION);
|
||||||
return 0;
|
return 0;
|
||||||
err_cgroup_ops:
|
|
||||||
genl_unregister_ops(&family, &taskstats_ops);
|
|
||||||
err:
|
|
||||||
genl_unregister_family(&family);
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user