diff options
author | Jiri Pirko <jiri@nvidia.com> | 2023-02-10 11:01:28 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-02-13 10:49:14 +0100 |
commit | fbcf938150ecd686c6a6195573957db25b43a182 (patch) | |
tree | 8ac880e372cadf6d9a851b956c193558c41db03d /net/devlink | |
parent | devlink: fix the name of value arg of devl_param_driverinit_value_get() (diff) | |
download | linux-fbcf938150ecd686c6a6195573957db25b43a182.tar.xz linux-fbcf938150ecd686c6a6195573957db25b43a182.zip |
devlink: use xa_for_each_start() helper in devlink_nl_cmd_port_get_dump_one()
As xarray has an iterator helper that allows to start from specified
index, use this directly and avoid repeated iteration from 0.
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/devlink')
-rw-r--r-- | net/devlink/leftover.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c index c3c82d5d563e..1f3332a6f1ac 100644 --- a/net/devlink/leftover.c +++ b/net/devlink/leftover.c @@ -1110,24 +1110,18 @@ devlink_nl_cmd_port_get_dump_one(struct sk_buff *msg, struct devlink *devlink, struct devlink_nl_dump_state *state = devlink_dump_state(cb); struct devlink_port *devlink_port; unsigned long port_index; - int idx = 0; int err = 0; - xa_for_each(&devlink->ports, port_index, devlink_port) { - if (idx < state->idx) { - idx++; - continue; - } + xa_for_each_start(&devlink->ports, port_index, devlink_port, state->idx) { err = devlink_nl_port_fill(msg, devlink_port, DEVLINK_CMD_NEW, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, NLM_F_MULTI, cb->extack); if (err) { - state->idx = idx; + state->idx = port_index; break; } - idx++; } return err; |