[v2,03/12] eal/pci: Rework loops in rte_pci_get_iommu_class

Message ID 20190530212959.1205097-3-benjamin.walker@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v2,01/12] eal: Make rte_eal_using_phys_addrs work sooner |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Walker, Benjamin May 30, 2019, 9:29 p.m. UTC
  Make all of the loops first iterate over devices, then
drivers. This is in preparation for combining them
into a single loop.

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

Patch

diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index d3177916a..70815e4f0 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -589,10 +589,10 @@  rte_pci_get_iommu_class(void)
 	if (!is_bound)
 		return RTE_IOVA_DC;
 
-	FOREACH_DRIVER_ON_PCIBUS(drv) {
-		if (drv && drv->drv_flags & RTE_PCI_DRV_IOVA_AS_VA) {
-			FOREACH_DEVICE_ON_PCIBUS(dev) {
-				if (dev->kdrv == RTE_KDRV_VFIO &&
+	FOREACH_DEVICE_ON_PCIBUS(dev) {
+		if (dev->kdrv == RTE_KDRV_VFIO) {
+			FOREACH_DRIVER_ON_PCIBUS(drv) {
+				if (drv->drv_flags & RTE_PCI_DRV_IOVA_AS_VA &&
 				    rte_pci_match(drv, dev)) {
 					has_iova_va = true;
 					break;
@@ -631,8 +631,8 @@  rte_pci_get_iommu_class(void)
 	}
 
 	break_out = false;
-	FOREACH_DRIVER_ON_PCIBUS(drv) {
-		FOREACH_DEVICE_ON_PCIBUS(dev) {
+	FOREACH_DEVICE_ON_PCIBUS(dev) {
+		FOREACH_DRIVER_ON_PCIBUS(drv) {
 			if (!rte_pci_match(drv, dev))
 				continue;
 			/*