pci: factor out pci_for_each_device().
authorIsaku Yamahata <yamahata@valinux.co.jp>
Fri, 30 Oct 2009 12:21:24 +0000 (21:21 +0900)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 9 Nov 2009 14:43:10 +0000 (08:43 -0600)
split out device iteration logic from pci_for_each_device().
factored out function, pci_for_each_device_under_bus() will be used later.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/pci.c

index b43f6c6..d565f6e 100644 (file)
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -885,19 +885,26 @@ static void pci_info_device(PCIBus *bus, PCIDevice *d)
     }
 }
 
-void pci_for_each_device(PCIBus *bus, int bus_num,
-                         void (*fn)(PCIBus *b, PCIDevice *d))
+static void pci_for_each_device_under_bus(PCIBus *bus,
+                                          void (*fn)(PCIBus *b, PCIDevice *d))
 {
     PCIDevice *d;
     int devfn;
 
+    for(devfn = 0; devfn < 256; devfn++) {
+        d = bus->devices[devfn];
+        if (d)
+            fn(bus, d);
+    }
+}
+
+void pci_for_each_device(PCIBus *bus, int bus_num,
+                         void (*fn)(PCIBus *b, PCIDevice *d))
+{
     bus = pci_find_bus(bus, bus_num);
+
     if (bus) {
-        for(devfn = 0; devfn < 256; devfn++) {
-            d = bus->devices[devfn];
-            if (d)
-                fn(bus, d);
-        }
+        pci_for_each_device_under_bus(bus, fn);
     }
 }