[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 02/12] pci: use qbus_create in pci_bus_new
From: |
Andreas Färber |
Subject: |
Re: [Qemu-devel] [PATCH v3 02/12] pci: use qbus_create in pci_bus_new |
Date: |
Fri, 25 Jan 2013 13:02:18 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130105 Thunderbird/17.0.2 |
Am 25.01.2013 12:46, schrieb Paolo Bonzini:
> 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.
>
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
> hw/pci/pci.c | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 5fd1bcf..82b0ef8 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(bus), TYPE_PCI_BUS, parent, name);
This needs to be (BusState*) as-is. The object initialization is done
inside qbus_create_inplace() after BUS(), resulting in an assertion.
In a previous version I therefore suggested to change the argument type
to void* to avoid such casts.
Otherwise looking good.
Regards,
Andreas
> + 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;
> }
>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
- [Qemu-devel] [PATCH for-1.4 v3 00/12] qdev: correct reference counting, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v3 11/12] cpu: do not use object_delete, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v3 01/12] qdev: remove duplication between qbus_create and qbus_create_inplace, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v3 08/12] qdev: add reference for the bus while it is referred to by the DeviceState, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v3 03/12] qom: preserve object while unparenting it, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v3 02/12] pci: use qbus_create in pci_bus_new, Paolo Bonzini, 2013/01/25
- Re: [Qemu-devel] [PATCH v3 02/12] pci: use qbus_create in pci_bus_new,
Andreas Färber <=
- [Qemu-devel] [PATCH v3 04/12] qom: document reference counting of link properties, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v3 05/12] qdev: add reference count to a device for the BusChild, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v3 09/12] qdev: inline object_delete into qbus_free/qdev_free, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v3 06/12] qdev: move deletion of children from finalize to unparent, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v3 07/12] qdev: move unrealization of devices from finalize to unparent, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v3 10/12] qdev: drop extra references at creation time, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v3 12/12] qom: remove object_delete, Paolo Bonzini, 2013/01/25