From f07e0ddf5abfe95b96c5aa26483b85a7e8fe150f Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Tue, 20 Nov 2018 21:49:39 +0100 Subject: [PATCH] pci: cleanup the detach code Very minor cleanup before we start refactoring the code. Change-Id: I00d768ec0c84f2a37c54b7575de695281c5ebb22 Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/434411 Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto Tested-by: Jim Harris --- lib/env_dpdk/pci.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/env_dpdk/pci.c b/lib/env_dpdk/pci.c index 7473125ca..c0fe829d0 100644 --- a/lib/env_dpdk/pci.c +++ b/lib/env_dpdk/pci.c @@ -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