mirror of https://gitee.com/openkylin/qemu.git
pci: factor out pci_for_each_device().
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>
This commit is contained in:
parent
a968857067
commit
1074df4f29
21
hw/pci.c
21
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,
|
static void pci_for_each_device_under_bus(PCIBus *bus,
|
||||||
void (*fn)(PCIBus *b, PCIDevice *d))
|
void (*fn)(PCIBus *b, PCIDevice *d))
|
||||||
{
|
{
|
||||||
PCIDevice *d;
|
PCIDevice *d;
|
||||||
int devfn;
|
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);
|
bus = pci_find_bus(bus, bus_num);
|
||||||
|
|
||||||
if (bus) {
|
if (bus) {
|
||||||
for(devfn = 0; devfn < 256; devfn++) {
|
pci_for_each_device_under_bus(bus, fn);
|
||||||
d = bus->devices[devfn];
|
|
||||||
if (d)
|
|
||||||
fn(bus, d);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue