From: Jan Blunck Date: Tue, 11 Apr 2017 15:44:08 +0000 (+0200) Subject: vdev: refactor probe/remove X-Git-Tag: spdx-start~3662 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=598639950bd535e159064c913fb92d55cbe61345;p=dpdk.git vdev: refactor probe/remove This is a preparation for the introduction of the struct rte_vdev_device. Signed-off-by: Jan Blunck Tested-by: Ferruh Yigit Acked-by: Shreyansh Jain --- diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index a94c4c6578..c255073a05 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -66,14 +66,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. @@ -94,18 +91,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. @@ -126,8 +134,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