bus: add iterator to find a bus
[dpdk.git] / lib / librte_eal / common / eal_common_bus.c
index 8f9baf8..3094daa 100644 (file)
@@ -145,3 +145,22 @@ rte_bus_dump(FILE *f)
                }
        }
 }
+
+struct rte_bus *
+rte_bus_find(const struct rte_bus *start, rte_bus_cmp_t cmp,
+            const void *data)
+{
+       struct rte_bus *bus = NULL;
+       bool start_found = !start;
+
+       TAILQ_FOREACH(bus, &rte_bus_list, next) {
+               if (!start_found) {
+                       if (bus == start)
+                               start_found = 1;
+                       continue;
+               }
+               if (cmp(bus, data) == 0)
+                       break;
+       }
+       return bus;
+}