pci: cleanup the detach code

Very minor cleanup before we start refactoring the code.

Change-Id: I00d768ec0c84f2a37c54b7575de695281c5ebb22
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/434411 (master)
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448372
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Darek Stojaczyk 2018-11-20 21:49:39 +01:00
parent 58ae282df8
commit 0cd37ba171

View File

@ -122,12 +122,13 @@ spdk_pci_device_attach(struct spdk_pci_enum_ctx *ctx,
spdk_pci_enum_cb enum_cb,
void *enum_ctx, struct spdk_pci_addr *pci_address)
{
int rc;
#if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 3)
char bdf[32];
char bdf[32];
spdk_pci_addr_fmt(bdf, sizeof(bdf), pci_address);
#else
struct rte_pci_addr addr;
struct rte_pci_addr addr;
addr.domain = pci_address->domain;
addr.bus = pci_address->bus;
@ -150,25 +151,20 @@ spdk_pci_device_attach(struct spdk_pci_enum_ctx *ctx,
ctx->cb_arg = enum_ctx;
#if RTE_VERSION >= RTE_VERSION_NUM(18, 11, 0, 0)
if (rte_eal_hotplug_add("pci", bdf, "") != 0) {
rc = rte_eal_hotplug_add("pci", bdf, "");
#elif RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 3)
if (rte_eal_dev_attach(bdf, "") != 0) {
rc = rte_eal_dev_attach(bdf, "");
#elif RTE_VERSION >= RTE_VERSION_NUM(17, 05, 0, 4)
if (rte_pci_probe_one(&addr) != 0) {
rc = rte_pci_probe_one(&addr);
#else
if (rte_eal_pci_probe_one(&addr) != 0) {
rc = rte_eal_pci_probe_one(&addr);
#endif
ctx->cb_arg = NULL;
ctx->cb_fn = NULL;
pthread_mutex_unlock(&g_pci_mutex);
return -1;
}
ctx->cb_arg = NULL;
ctx->cb_fn = NULL;
pthread_mutex_unlock(&g_pci_mutex);
return 0;
return rc == 0 ? 0 : -1;
}
/* Note: You can call spdk_pci_enumerate from more than one thread