/* Returns 0 on success or a negative error code.  */
int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
/* Returns 0 on success or a negative error code.  */
int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
{
	int err = -EINVAL;
	if (ops->dumpit == NULL && ops->doit == NULL)
		goto errout;
	if (genl_get_cmd(ops->cmd, family)) {
		err = -EEXIST;
		goto errout;
	}
	if (ops->dumpit)
		ops->flags |= GENL_CMD_CAP_DUMP;
	if (ops->doit)
		ops->flags |= GENL_CMD_CAP_DO;
	if (ops->policy)
		ops->flags |= GENL_CMD_CAP_HASPOL;
	genl_lock();
	list_add_tail(&ops->ops_list, &family->ops_list);
	genl_unlock();
	genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
	err = 0;
errout:
	return err;
}