mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
ethtool: netlink: simplify arguments to ethnl_default_parse()
Pass struct genl_info directly instead of its members. Reviewed-by: Jiri Pirko <jiri@nvidia.com> Link: https://lore.kernel.org/r/20230814214723.2924989-10-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
0e19d3108a
commit
ec0e5b09b8
@ -316,10 +316,8 @@ static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *cb)
|
|||||||
/**
|
/**
|
||||||
* ethnl_default_parse() - Parse request message
|
* ethnl_default_parse() - Parse request message
|
||||||
* @req_info: pointer to structure to put data into
|
* @req_info: pointer to structure to put data into
|
||||||
* @tb: parsed attributes
|
* @info: genl_info from the request
|
||||||
* @net: request netns
|
|
||||||
* @request_ops: struct request_ops for request type
|
* @request_ops: struct request_ops for request type
|
||||||
* @extack: netlink extack for error reporting
|
|
||||||
* @require_dev: fail if no device identified in header
|
* @require_dev: fail if no device identified in header
|
||||||
*
|
*
|
||||||
* Parse universal request header and call request specific ->parse_request()
|
* Parse universal request header and call request specific ->parse_request()
|
||||||
@ -328,19 +326,21 @@ static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *cb)
|
|||||||
* Return: 0 on success or negative error code
|
* Return: 0 on success or negative error code
|
||||||
*/
|
*/
|
||||||
static int ethnl_default_parse(struct ethnl_req_info *req_info,
|
static int ethnl_default_parse(struct ethnl_req_info *req_info,
|
||||||
struct nlattr **tb, struct net *net,
|
const struct genl_info *info,
|
||||||
const struct ethnl_request_ops *request_ops,
|
const struct ethnl_request_ops *request_ops,
|
||||||
struct netlink_ext_ack *extack, bool require_dev)
|
bool require_dev)
|
||||||
{
|
{
|
||||||
|
struct nlattr **tb = info->attrs;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = ethnl_parse_header_dev_get(req_info, tb[request_ops->hdr_attr],
|
ret = ethnl_parse_header_dev_get(req_info, tb[request_ops->hdr_attr],
|
||||||
net, extack, require_dev);
|
genl_info_net(info), info->extack,
|
||||||
|
require_dev);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (request_ops->parse_request) {
|
if (request_ops->parse_request) {
|
||||||
ret = request_ops->parse_request(req_info, tb, extack);
|
ret = request_ops->parse_request(req_info, tb, info->extack);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -393,8 +393,7 @@ static int ethnl_default_doit(struct sk_buff *skb, struct genl_info *info)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ethnl_default_parse(req_info, info->attrs, genl_info_net(info),
|
ret = ethnl_default_parse(req_info, info, ops, !ops->allow_nodev_do);
|
||||||
ops, info->extack, !ops->allow_nodev_do);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err_dev;
|
goto err_dev;
|
||||||
ethnl_init_reply_data(reply_data, ops, req_info->dev);
|
ethnl_init_reply_data(reply_data, ops, req_info->dev);
|
||||||
@ -538,9 +537,7 @@ static int ethnl_default_start(struct netlink_callback *cb)
|
|||||||
goto free_req_info;
|
goto free_req_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ethnl_default_parse(req_info, info->info.attrs,
|
ret = ethnl_default_parse(req_info, &info->info, ops, false);
|
||||||
sock_net(cb->skb->sk),
|
|
||||||
ops, cb->extack, false);
|
|
||||||
if (req_info->dev) {
|
if (req_info->dev) {
|
||||||
/* We ignore device specification in dump requests but as the
|
/* We ignore device specification in dump requests but as the
|
||||||
* same parser as for non-dump (doit) requests is used, it
|
* same parser as for non-dump (doit) requests is used, it
|
||||||
|
Loading…
Reference in New Issue
Block a user