Signed-off-by: Jan Blunck <jblu...@infradead.org> --- lib/librte_eal/common/eal_common_devargs.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index 92c77c30e..691538095 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -137,6 +137,14 @@ rte_eal_devargs_parse(const char *dev, struct rte_devargs *da) return 0; } +static const struct rte_bus_conf BUS_CONF_WHITELIST = { + .scan_mode = RTE_BUS_SCAN_WHITELIST, +}; + +static const struct rte_bus_conf BUS_CONF_BLACKLIST = { + .scan_mode = RTE_BUS_SCAN_BLACKLIST, +}; + /* store a whitelist parameter for later parsing */ int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) @@ -144,6 +152,7 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) struct rte_devargs *devargs = NULL; struct rte_bus *bus = NULL; const char *dev = devargs_str; + int ret; /* use calloc instead of rte_zmalloc as it's called early at init */ devargs = calloc(1, sizeof(*devargs)); @@ -154,20 +163,13 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) goto fail; devargs->type = devtype; bus = devargs->bus; - if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) { - if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) { - bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST; - } else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) { - fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n"); - goto fail; - } - } else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) { - if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) { - bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST; - } else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) { - fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n"); - goto fail; - } + ret = rte_bus_configure(bus, + devtype == RTE_DEVTYPE_WHITELISTED_PCI ? + &BUS_CONF_WHITELIST : &BUS_CONF_WHITELIST); + if (ret != 0) { + RTE_LOG(ERR, EAL, + "incompatible device type and bus scan mode\n"); + goto fail; } TAILQ_INSERT_TAIL(&devargs_list, devargs, next); -- 2.13.2