[2/3] net/nfb: make device path local to init function

Message ID 20231207185720.19913-3-stephen@networkplumber.org (mailing list archive)
State Accepted
Delegated to: Ferruh Yigit
Headers
Series net/nfb: driver cleanups |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Dec. 7, 2023, 6:56 p.m. UTC
  The device path is only used to call nfb_open() it does
not have to be stored in internal structure.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/nfb/nfb.h        | 2 --
 drivers/net/nfb/nfb_ethdev.c | 8 ++++----
 2 files changed, 4 insertions(+), 6 deletions(-)
  

Patch

diff --git a/drivers/net/nfb/nfb.h b/drivers/net/nfb/nfb.h
index 21cd8f78f641..2707f3db6240 100644
--- a/drivers/net/nfb/nfb.h
+++ b/drivers/net/nfb/nfb.h
@@ -42,8 +42,6 @@  struct pmd_internals {
 	uint16_t         max_txmac;
 	struct nc_rxmac *rxmac[RTE_MAX_NC_RXMAC];
 	struct nc_txmac *txmac[RTE_MAX_NC_TXMAC];
-
-	char             nfb_dev[PATH_MAX];
 	struct nfb_device *nfb;
 };
 
diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c
index 4c4e2e3273e6..892abe81f3d6 100644
--- a/drivers/net/nfb/nfb_ethdev.c
+++ b/drivers/net/nfb/nfb_ethdev.c
@@ -518,12 +518,13 @@  nfb_eth_dev_init(struct rte_eth_dev *dev)
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_pci_addr *pci_addr = &pci_dev->addr;
 	struct rte_ether_addr eth_addr_init;
+	char nfb_dev[PATH_MAX];
 
 	RTE_LOG(INFO, PMD, "Initializing NFB device (" PCI_PRI_FMT ")\n",
 		pci_addr->domain, pci_addr->bus, pci_addr->devid,
 		pci_addr->function);
 
-	snprintf(internals->nfb_dev, PATH_MAX,
+	snprintf(nfb_dev, sizeof(nfb_dev),
 		"/dev/nfb/by-pci-slot/" PCI_PRI_FMT,
 		pci_addr->domain, pci_addr->bus, pci_addr->devid,
 		pci_addr->function);
@@ -533,10 +534,9 @@  nfb_eth_dev_init(struct rte_eth_dev *dev)
 	 * number of queues that can be created and store it in private device
 	 * data structure.
 	 */
-	internals->nfb = nfb_open(internals->nfb_dev);
+	internals->nfb = nfb_open(nfb_dev);
 	if (internals->nfb == NULL) {
-		RTE_LOG(ERR, PMD, "nfb_open(): failed to open %s",
-			internals->nfb_dev);
+		RTE_LOG(ERR, PMD, "nfb_open(): failed to open %s", nfb_dev);
 		return -EINVAL;
 	}
 	data->nb_rx_queues = ndp_get_rx_queue_available_count(internals->nfb);