[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/2] pci/bridge: allocate PCIBus dynamically for PCI
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH 1/2] pci/bridge: allocate PCIBus dynamically for PCIBridge. |
Date: |
Fri, 2 Jul 2010 11:30:11 +0900 |
allocate PCIBus dynamically for PCIBridge and bug fix of
pci_unregister_secondary_bus().
This is a preparation for splitting out pci_bridge functions.
Since PCIBus is private to pci.c, PCIBridge won't be able to
contain PCIBus in its structure.
Signed-off-by: Isaku Yamahata <address@hidden>
---
hw/pci.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 08652e8..fdf02d0 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -286,23 +286,27 @@ PCIBus *pci_register_bus(DeviceState *parent, const char
*name,
return bus;
}
-static void pci_register_secondary_bus(PCIBus *parent,
- PCIBus *bus,
- PCIDevice *dev,
- pci_map_irq_fn map_irq,
- const char *name)
+static PCIBus *pci_register_secondary_bus(PCIBus *parent,
+ PCIDevice *dev,
+ pci_map_irq_fn map_irq,
+ const char *name)
{
- qbus_create_inplace(&bus->qbus, &pci_bus_info, &dev->qdev, name);
+ PCIBus *bus;
+ bus = pci_bus_new(&dev->qdev, name, 0);
+
bus->map_irq = map_irq;
bus->parent_dev = dev;
QLIST_INSERT_HEAD(&parent->child, bus, sibling);
+
+ return bus;
}
static void pci_unregister_secondary_bus(PCIBus *bus)
{
assert(QLIST_EMPTY(&bus->child));
QLIST_REMOVE(bus, sibling);
+ qbus_free(&bus->qbus);
}
int pci_bus_num(PCIBus *s)
@@ -1527,7 +1531,7 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char
*default_model,
typedef struct {
PCIDevice dev;
- PCIBus bus;
+ PCIBus *bus;
uint32_t vid;
uint32_t did;
} PCIBridge;
@@ -1628,8 +1632,7 @@ static int pci_bridge_initfn(PCIDevice *dev)
static int pci_bridge_exitfn(PCIDevice *pci_dev)
{
PCIBridge *s = DO_UPCAST(PCIBridge, dev, pci_dev);
- PCIBus *bus = &s->bus;
- pci_unregister_secondary_bus(bus);
+ pci_unregister_secondary_bus(s->bus);
return 0;
}
@@ -1646,8 +1649,8 @@ PCIBus *pci_bridge_init(PCIBus *bus, int devfn, bool
multifunction,
qdev_init_nofail(&dev->qdev);
s = DO_UPCAST(PCIBridge, dev, dev);
- pci_register_secondary_bus(bus, &s->bus, &s->dev, map_irq, name);
- return &s->bus;
+ s->bus = pci_register_secondary_bus(bus, &s->dev, map_irq, name);
+ return s->bus;
}
PCIDevice *pci_bridge_get_device(PCIBus *bus)
--
1.7.1.1
- [Qemu-devel] [PATCH 0/2] pci: split out bridge code into pci_bridge, Isaku Yamahata, 2010/07/01
- [Qemu-devel] [PATCH 1/2] pci/bridge: allocate PCIBus dynamically for PCIBridge.,
Isaku Yamahata <=
- [Qemu-devel] Re: [PATCH 1/2] pci/bridge: allocate PCIBus dynamically for PCIBridge., Michael S. Tsirkin, 2010/07/06
- [Qemu-devel] Re: [PATCH 1/2] pci/bridge: allocate PCIBus dynamically for PCIBridge., Michael S. Tsirkin, 2010/07/08
- Re: [Qemu-devel] Re: [PATCH 1/2] pci/bridge: allocate PCIBus dynamically for PCIBridge., Isaku Yamahata, 2010/07/08
- Re: [Qemu-devel] Re: [PATCH 1/2] pci/bridge: allocate PCIBus dynamically for PCIBridge., Michael S. Tsirkin, 2010/07/08
- Re: [Qemu-devel] Re: [PATCH 1/2] pci/bridge: allocate PCIBus dynamically for PCIBridge., Isaku Yamahata, 2010/07/08
- Re: [Qemu-devel] Re: [PATCH 1/2] pci/bridge: allocate PCIBus dynamically for PCIBridge., Isaku Yamahata, 2010/07/15
- Re: [Qemu-devel] Re: [PATCH 1/2] pci/bridge: allocate PCIBus dynamically for PCIBridge., Michael S. Tsirkin, 2010/07/16