summaryrefslogtreecommitdiff
path: root/net/devlink
diff options
context:
space:
mode:
authorJiri Pirko <jiri@nvidia.com>2023-01-18 18:21:14 +0300
committerJakub Kicinski <kuba@kernel.org>2023-01-20 06:08:38 +0300
commit543753d9e22e3943e2c31c4b5241afafb55dd52a (patch)
tree946a7f59849742f5cf476bc76e477d8a2e2069b1 /net/devlink
parent19be51a93d9986edcfecae010920ab1d5714479b (diff)
downloadlinux-543753d9e22e3943e2c31c4b5241afafb55dd52a.tar.xz
devlink: remove devlink_dump_for_each_instance_get() helper
devlink_dump_for_each_instance_get() is currently called from a single place in netlink.c. As there is no need to use this helper anywhere else in the future, remove it and call devlinks_xa_find_get() directly from while loop in devlink_nl_instance_iter_dump(). Also remove redundant idx clear on loop end as it is already done in devlink_nl_instance_iter_dump(). Signed-off-by: Jiri Pirko <jiri@nvidia.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/devlink')
-rw-r--r--net/devlink/devl_internal.h11
-rw-r--r--net/devlink/netlink.c5
2 files changed, 4 insertions, 12 deletions
diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h
index 10975e4ea2f4..75752f8c4a26 100644
--- a/net/devlink/devl_internal.h
+++ b/net/devlink/devl_internal.h
@@ -123,17 +123,6 @@ struct devlink_gen_cmd {
struct netlink_callback *cb);
};
-/* Iterate over registered devlink instances for devlink dump.
- * devlink_put() needs to be called for each iterated devlink pointer
- * in loop body in order to release the reference.
- * Note: this is NOT a generic iterator, it makes assumptions about the use
- * of @state and can only be used once per dumpit implementation.
- */
-#define devlink_dump_for_each_instance_get(msg, state, devlink) \
- for (; (devlink = devlinks_xa_find_get(sock_net(msg->sk), \
- &state->instance)); \
- state->instance++, state->idx = 0)
-
extern const struct genl_small_ops devlink_nl_ops[56];
struct devlink *
diff --git a/net/devlink/netlink.c b/net/devlink/netlink.c
index d4539c1aedea..3f44633af01c 100644
--- a/net/devlink/netlink.c
+++ b/net/devlink/netlink.c
@@ -207,7 +207,8 @@ int devlink_nl_instance_iter_dump(struct sk_buff *msg,
cmd = devl_gen_cmds[info->op.cmd];
- devlink_dump_for_each_instance_get(msg, state, devlink) {
+ while ((devlink = devlinks_xa_find_get(sock_net(msg->sk),
+ &state->instance))) {
devl_lock(devlink);
if (devl_is_registered(devlink))
@@ -221,6 +222,8 @@ int devlink_nl_instance_iter_dump(struct sk_buff *msg,
if (err)
break;
+ state->instance++;
+
/* restart sub-object walk for the next instance */
state->idx = 0;
}