summaryrefslogtreecommitdiff
path: root/net/ethtool/module.c
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2023-01-25 15:05:18 -0800
committerDavid S. Miller <davem@davemloft.net>2023-01-27 12:24:31 +0000
commit99132b6eb7927a549351f57638a1d560039f06f9 (patch)
tree1213efe6b6db7c26dadab69f00d4af2db81c618d /net/ethtool/module.c
parentc766e077d927e1775902c18827205ea2ade3a35d (diff)
ethtool: netlink: handle SET intro/outro in the common code
Most ethtool SET callbacks follow the same general structure. ethnl_parse_header_dev_get() rtnl_lock() ethnl_ops_begin() ... do stuff ... ethtool_notify() ethnl_ops_complete() rtnl_unlock() ethnl_parse_header_dev_put() This leads to a lot of copy / pasted code an bugs when people mis-handle the error path. Add a generic implementation of this pattern with a .set callback in struct ethnl_request_ops called to "do stuff". Also add an optional .set_validate which is called before ethnl_ops_begin() -- a lot of implementations do basic request capability / sanity checking at that point. Because we want to avoid generating the notification when no change happened - adopt a slightly hairy return values: - 0 means nothing to do (no notification) - 1 means done / continue - negative error codes on error Reuse .hdr_attr from struct ethnl_request_ops, GET and SET use the same attr spaces in all cases. Convert pause as an example (and to avoid unused function warnings). Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ethtool/module.c')
0 files changed, 0 insertions, 0 deletions