From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2 1/2] pci: add pci_for_each_bus
Date: Thu, 11 Jul 2013 15:04:00 +0300 [thread overview]
Message-ID: <1373544219-25608-2-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1373544219-25608-1-git-send-email-mst@redhat.com>
Useful for ACPI hotplug.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/pci/pci.c | 17 +++++++++++++++++
include/hw/pci/pci.h | 3 +++
2 files changed, 20 insertions(+)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 8680063..a4f7f8d 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1679,6 +1679,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 209dda4..a82c1c7 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -391,6 +391,9 @@ 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_primary_bus(void);
PCIBus *pci_device_root_bus(const PCIDevice *d);
const char *pci_root_bus_path(PCIDevice *dev);
--
MST
next prev parent reply other threads:[~2013-07-11 12:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-11 12:03 [Qemu-devel] [PATCH v2 0/2] acpi hotplug of devices behind a bridge Michael S. Tsirkin
2013-07-11 12:04 ` Michael S. Tsirkin [this message]
2013-07-11 12:04 ` [Qemu-devel] [PATCH v2 2/2] qemu: piix: PCI bridge ACPI hotplug support Michael S. Tsirkin
2013-07-11 12:09 ` [Qemu-devel] [PATCH v2 0/2] acpi hotplug of devices behind a bridge Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1373544219-25608-2-git-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).