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
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Darek Stojaczyk 2018-11-20 21:49:39 +01:00 committed by Jim Harris
parent 1b7c0f54d0
commit f07e0ddf5a

View File

@ -122,6 +122,7 @@ spdk_pci_device_attach(struct spdk_pci_enum_ctx *ctx,
spdk_pci_enum_cb enum_cb, spdk_pci_enum_cb enum_cb,
void *enum_ctx, struct spdk_pci_addr *pci_address) void *enum_ctx, struct spdk_pci_addr *pci_address)
{ {
int rc;
#if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 3) #if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 3)
char bdf[32]; char bdf[32];
@ -150,25 +151,20 @@ spdk_pci_device_attach(struct spdk_pci_enum_ctx *ctx,
ctx->cb_arg = enum_ctx; ctx->cb_arg = enum_ctx;
#if RTE_VERSION >= RTE_VERSION_NUM(18, 11, 0, 0) #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) #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) #elif RTE_VERSION >= RTE_VERSION_NUM(17, 05, 0, 4)
if (rte_pci_probe_one(&addr) != 0) { rc = rte_pci_probe_one(&addr);
#else #else
if (rte_eal_pci_probe_one(&addr) != 0) { rc = rte_eal_pci_probe_one(&addr);
#endif #endif
ctx->cb_arg = NULL;
ctx->cb_fn = NULL;
pthread_mutex_unlock(&g_pci_mutex);
return -1;
}
ctx->cb_arg = NULL; ctx->cb_arg = NULL;
ctx->cb_fn = NULL; ctx->cb_fn = NULL;
pthread_mutex_unlock(&g_pci_mutex); 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 /* Note: You can call spdk_pci_enumerate from more than one thread