diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2019-04-24 14:19:58 +1000 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2019-05-20 18:40:02 -0400 |
commit | b0e5196a52248d7e4eef709481c1c530c1bca6df (patch) | |
tree | 6008b4126f8c073bf311599a4b7ea99fbf650dbf /hw/pci | |
parent | c76efd7225d33b48f7a1dd4519620f0b50267612 (diff) |
pci: Simplify pci_bus_is_root()
pci_bus_is_root() currently relies on a method in the PCIBusClass.
But it's always known if a PCI bus is a root bus when we create it, so
using a dynamic method is overkill.
This replaces it with an IS_ROOT bit in a new flags field, which is set on
root buses and otherwise clear. As a bonus this removes the special
is_root logic from pci_expander_bridge, since it already creates its bus
as a root bus.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <20190424041959.4087-3-david@gibson.dropbear.id.au>
Diffstat (limited to 'hw/pci')
-rw-r--r-- | hw/pci/pci.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/hw/pci/pci.c b/hw/pci/pci.c index a78023f669..b386777045 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -129,14 +129,9 @@ static void pci_bus_unrealize(BusState *qbus, Error **errp) vmstate_unregister(NULL, &vmstate_pcibus, bus); } -static bool pcibus_is_root(PCIBus *bus) -{ - return !bus->parent_dev; -} - static int pcibus_num(PCIBus *bus) { - if (pcibus_is_root(bus)) { + if (pci_bus_is_root(bus)) { return 0; /* pci host bridge */ } return bus->parent_dev->config[PCI_SECONDARY_BUS]; @@ -164,7 +159,6 @@ static void pci_bus_class_init(ObjectClass *klass, void *data) k->unrealize = pci_bus_unrealize; k->reset = pcibus_reset; - pbc->is_root = pcibus_is_root; pbc->bus_num = pcibus_num; pbc->numa_node = pcibus_numa_node; pbc->allows_extended_config_space = pcibus_allows_extended_config_space; @@ -398,6 +392,7 @@ static void pci_root_bus_init(PCIBus *bus, DeviceState *parent, bus->slot_reserved_mask = 0x0; bus->address_space_mem = address_space_mem; bus->address_space_io = address_space_io; + bus->flags |= PCI_BUS_IS_ROOT; /* host bridge */ QLIST_INIT(&bus->child); @@ -415,11 +410,6 @@ bool pci_bus_is_express(PCIBus *bus) return object_dynamic_cast(OBJECT(bus), TYPE_PCIE_BUS); } -bool pci_bus_is_root(PCIBus *bus) -{ - return PCI_BUS_GET_CLASS(bus)->is_root(bus); -} - bool pci_bus_allows_extended_config_space(PCIBus *bus) { return PCI_BUS_GET_CLASS(bus)->allows_extended_config_space(bus); |