* [Qemu-devel] [PATCH RFC] pci: add pci_for_each_bus
@ 2013-06-10 16:26 Michael S. Tsirkin
0 siblings, 0 replies; only message in thread
From: Michael S. Tsirkin @ 2013-06-10 16:26 UTC (permalink / raw)
To: qemu-devel
This will be useful for bridge ACPI hotplug.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/pci/pci.c | 17 +++++++++++++++++
include/hw/pci/pci.h | 4 ++++
2 files changed, 21 insertions(+)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index d5257ed..130b5ad 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1677,6 +1677,23 @@ static PCIBus *pci_find_bus_nr(PCIBus *bus, int bus_num)
return NULL;
}
+void pci_for_each_bus(PCIBus *bus,
+ void (*fn)(PCIBus *bus, void *opaque),
+ void *opaque)
+{
+ PCIBus *sec;
+
+ if (!bus) {
+ return;
+ }
+
+ fn(bus, opaque);
+
+ QLIST_FOREACH(sec, &bus->child, sibling) {
+ pci_for_each_bus(sec, fn, opaque);
+ }
+}
+
PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn)
{
bus = pci_find_bus_nr(bus, bus_num);
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 8d075ab..d6dc02f 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -390,6 +390,10 @@ int pci_bus_num(PCIBus *s);
void pci_for_each_device(PCIBus *bus, int bus_num,
void (*fn)(PCIBus *bus, PCIDevice *d, void *opaque),
void *opaque);
+
+void pci_for_each_bus(PCIBus *bus,
+ void (*fn)(PCIBus *bus, void *opaque),
+ void *opaque);
PCIBus *pci_find_root_bus(int domain);
int pci_find_domain(const PCIBus *bus);
PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn);
--
MST
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-06-10 16:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-10 16:26 [Qemu-devel] [PATCH RFC] pci: add pci_for_each_bus Michael S. Tsirkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).