From a294e58c80a8c012d064247b1b242604ba6042a9 Mon Sep 17 00:00:00 2001 From: Michael Baum Date: Wed, 24 Jun 2020 13:23:57 +0000 Subject: [PATCH] net/mlx5: use direct API to find port by device Using RTE_ETH_FOREACH_DEV_OF loop is not necessary when the driver wants to find only the first match. Use rte_eth_find_next_of to find it. Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_mr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c index adbe07c4c7..3b781b68ae 100644 --- a/drivers/net/mlx5/mlx5_mr.c +++ b/drivers/net/mlx5/mlx5_mr.c @@ -313,9 +313,10 @@ pci_dev_to_eth_dev(struct rte_pci_device *pdev) { uint16_t port_id; - RTE_ETH_FOREACH_DEV_OF(port_id, &pdev->device) - return &rte_eth_devices[port_id]; - return NULL; + port_id = rte_eth_find_next_of(0, &pdev->device); + if (port_id == RTE_MAX_ETHPORTS) + return NULL; + return &rte_eth_devices[port_id]; } /** -- 2.20.1