diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2013-01-25 14:12:29 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-02-01 15:53:09 -0600 |
commit | 4fec6404465fdb1f09670b1451605c7cbf87c01e (patch) | |
tree | 6e8f35e5616079865f733de66fde941b192d721c /hw | |
parent | 39355c3826f5d9a2eb1ce3dc9b4cdd68893769d6 (diff) |
pci: use qbus_create in pci_bus_new
Remove knowledge of QOM innards. The common part of pci_bus_new and
pci_bus_new_inplace is moved to a new function pci_bus_init.
Acked-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/pci/pci.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 5fd1bcf08e..905dc4a219 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -274,13 +274,12 @@ int pci_find_domain(const PCIBus *bus) return -1; } -void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent, +static void pci_bus_init(PCIBus *bus, DeviceState *parent, const char *name, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, uint8_t devfn_min) { - qbus_create_inplace(&bus->qbus, TYPE_PCI_BUS, parent, name); assert(PCI_FUNC(devfn_min) == 0); bus->devfn_min = devfn_min; bus->address_space_mem = address_space_mem; @@ -293,6 +292,17 @@ void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent, vmstate_register(NULL, -1, &vmstate_pcibus, bus); } +void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent, + const char *name, + MemoryRegion *address_space_mem, + MemoryRegion *address_space_io, + uint8_t devfn_min) +{ + qbus_create_inplace(bus, TYPE_PCI_BUS, parent, name); + pci_bus_init(bus, parent, name, address_space_mem, + address_space_io, devfn_min); +} + PCIBus *pci_bus_new(DeviceState *parent, const char *name, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, @@ -300,10 +310,9 @@ PCIBus *pci_bus_new(DeviceState *parent, const char *name, { PCIBus *bus; - bus = g_malloc0(sizeof(*bus)); - pci_bus_new_inplace(bus, parent, name, address_space_mem, - address_space_io, devfn_min); - OBJECT(bus)->free = g_free; + bus = PCI_BUS(qbus_create(TYPE_PCI_BUS, parent, name)); + pci_bus_init(bus, parent, name, address_space_mem, + address_space_io, devfn_min); return bus; } |