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 *
 
 
        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))
                if (err)
                        break;
 
+               state->instance++;
+
                /* restart sub-object walk for the next instance */
                state->idx = 0;
        }