From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxFaH-0004Qt-BB for qemu-devel@nongnu.org; Thu, 11 Jul 2013 08:02:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UxFa9-0000P9-PV for qemu-devel@nongnu.org; Thu, 11 Jul 2013 08:02:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxFa9-0000Oz-Hu for qemu-devel@nongnu.org; Thu, 11 Jul 2013 08:02:45 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r6BC2iER001871 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 11 Jul 2013 08:02:45 -0400 Received: from redhat.com (vpn1-7-228.ams2.redhat.com [10.36.7.228]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id r6BC2hCg026180 for ; Thu, 11 Jul 2013 08:02:44 -0400 Date: Thu, 11 Jul 2013 15:04:00 +0300 From: "Michael S. Tsirkin" Message-ID: <1373544219-25608-2-git-send-email-mst@redhat.com> References: <1373544219-25608-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1373544219-25608-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PATCH v2 1/2] pci: add pci_for_each_bus List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Useful for ACPI hotplug. Signed-off-by: Michael S. Tsirkin --- 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