summaryrefslogtreecommitdiff
path: root/lib/librte_eal/common/eal_common_bus.c
diff options
context:
space:
mode:
authorJan Blunck <jblunck@infradead.org>2017-06-30 20:19:30 +0200
committerThomas Monjalon <thomas@monjalon.net>2017-07-04 01:08:11 +0200
commit87bfa873afebbf73355310e25c2d19e9825c1e24 (patch)
treeda36922653897cff51a3b7b1c3bc7e66c7b880ba /lib/librte_eal/common/eal_common_bus.c
parentfea892e35f211d1f7aa4991dd415a9b5f40dad76 (diff)
downloaddpdk-87bfa873afebbf73355310e25c2d19e9825c1e24.zip
dpdk-87bfa873afebbf73355310e25c2d19e9825c1e24.tar.gz
dpdk-87bfa873afebbf73355310e25c2d19e9825c1e24.tar.xz
bus: add iterator to find a bus
This helper allows to iterate over all registered buses and find one matching data used as parameter. Signed-off-by: Jan Blunck <jblunck@infradead.org> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
Diffstat (limited to 'lib/librte_eal/common/eal_common_bus.c')
-rw-r--r--lib/librte_eal/common/eal_common_bus.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index 8f9baf8..3094daa 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -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;
+}