This is a preparation for the introduction of the struct rte_vdev_device.

Signed-off-by: Jan Blunck <jblu...@infradead.org>
Tested-by: Ferruh Yigit <ferruh.yi...@intel.com>
---
 lib/librte_eal/common/eal_common_vdev.c | 44 ++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 11 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_vdev.c 
b/lib/librte_eal/common/eal_common_vdev.c
index 523a3d6..6ba3c91 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -61,14 +61,11 @@ rte_eal_vdrv_unregister(struct rte_vdev_driver *driver)
        TAILQ_REMOVE(&vdev_driver_list, driver, next);
 }
 
-int
-rte_eal_vdev_init(const char *name, const char *args)
+static int
+vdev_probe_all_drivers(const char *name, const char *args)
 {
        struct rte_vdev_driver *driver;
 
-       if (name == NULL)
-               return -EINVAL;
-
        TAILQ_FOREACH(driver, &vdev_driver_list, next) {
                /*
                 * search a driver prefix in virtual device name.
@@ -89,18 +86,29 @@ rte_eal_vdev_init(const char *name, const char *args)
                        return driver->probe(name, args);
        }
 
-       RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
-       return -EINVAL;
+       return 1;
 }
 
 int
-rte_eal_vdev_uninit(const char *name)
+rte_eal_vdev_init(const char *name, const char *args)
 {
-       struct rte_vdev_driver *driver;
+       int ret;
 
        if (name == NULL)
                return -EINVAL;
 
+       ret = vdev_probe_all_drivers(name, args);
+       if (ret  > 0)
+               RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
+
+       return ret;
+}
+
+static int
+vdev_remove_driver(const char *name)
+{
+       struct rte_vdev_driver *driver;
+
        TAILQ_FOREACH(driver, &vdev_driver_list, next) {
                /*
                 * search a driver prefix in virtual device name.
@@ -121,8 +129,22 @@ rte_eal_vdev_uninit(const char *name)
                        return driver->remove(name);
        }
 
-       RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
-       return -EINVAL;
+       return 1;
+}
+
+int
+rte_eal_vdev_uninit(const char *name)
+{
+       int ret;
+
+       if (name == NULL)
+               return -EINVAL;
+
+       ret = vdev_remove_driver(name);
+       if (ret > 0)
+               RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
+
+       return ret;
 }
 
 static int
-- 
2.7.4

Reply via email to