[dpdk-dev] [PATCH v2 09/12] eal/pci: Simplify rte_pci_get_iommu class by using a switch

Ben Walker benjamin.walker at intel.com
Thu May 30 23:29:56 CEST 2019


Take several independent if statements and convert to a
switch statement.

Signed-off-by: Ben Walker <benjamin.walker at intel.com>
---
 drivers/bus/pci/linux/pci.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index 765c473e8..5e61f46c8 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -601,12 +601,12 @@ rte_pci_get_iommu_class(void)
 		if (pci_ignore_device(dev))
 			continue;
 
-		if (dev->kdrv != RTE_KDRV_UNKNOWN &&
-		    dev->kdrv != RTE_KDRV_NONE) {
+		switch (dev->kdrv) {
+		case RTE_KDRV_UNKNOWN:
+		case RTE_KDRV_NONE:
+			break;
+		case RTE_KDRV_VFIO:
 			is_bound = true;
-		}
-
-		if (dev->kdrv == RTE_KDRV_VFIO) {
 			FOREACH_DRIVER_ON_PCIBUS(drv) {
 				if (!rte_pci_match(drv, dev))
 					continue;
@@ -622,11 +622,14 @@ rte_pci_get_iommu_class(void)
 					break;
 				}
 			}
-		}
-
-		if (dev->kdrv == RTE_KDRV_IGB_UIO ||
-		   dev->kdrv == RTE_KDRV_UIO_GENERIC) {
+			break;
+		case RTE_KDRV_IGB_UIO:
+		case RTE_KDRV_UIO_GENERIC:
+		case RTE_KDRV_NIC_UIO:
+			is_bound = true;
 			is_bound_uio = true;
+			break;
+
 		}
 	}
 
-- 
2.20.1



More information about the dev mailing list