bus: fix driver registration
[dpdk.git] / lib / librte_eal / common / eal_common_bus.c
index b8a9e30..96eb4fd 100644 (file)
@@ -51,6 +51,8 @@ rte_bus_register(struct rte_bus *bus)
        RTE_VERIFY(bus->scan);
        RTE_VERIFY(bus->probe);
        RTE_VERIFY(bus->find_device);
+       /* Buses supporting driver plug also require unplug. */
+       RTE_VERIFY(!bus->plug || bus->unplug);
 
        TAILQ_INSERT_TAIL(&rte_bus_list, bus, next);
        RTE_LOG(DEBUG, EAL, "Registered [%s] bus.\n", bus->name);
@@ -90,7 +92,7 @@ rte_bus_probe(void)
        struct rte_bus *bus, *vbus = NULL;
 
        TAILQ_FOREACH(bus, &rte_bus_list, next) {
-               if (!strcmp(bus->name, "virtual")) {
+               if (!strcmp(bus->name, "vdev")) {
                        vbus = bus;
                        continue;
                }
@@ -152,12 +154,10 @@ 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;
+               if (start && bus == start) {
+                       start = NULL; /* starting point found */
                        continue;
                }
                if (cmp(bus, data) == 0)
@@ -188,3 +188,17 @@ rte_bus_find_by_device(const struct rte_device *dev)
 {
        return rte_bus_find(NULL, bus_find_device, (const void *)dev);
 }
+
+static int
+cmp_bus_name(const struct rte_bus *bus, const void *_name)
+{
+       const char *name = _name;
+
+       return strcmp(bus->name, name);
+}
+
+struct rte_bus *
+rte_bus_find_by_name(const char *busname)
+{
+       return rte_bus_find(NULL, cmp_bus_name, (const void *)busname);
+}