From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:53247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SuNBd-0000jr-13 for qemu-devel@nongnu.org; Thu, 26 Jul 2012 08:29:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SuNBV-0007bW-80 for qemu-devel@nongnu.org; Thu, 26 Jul 2012 08:29:00 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Thu, 26 Jul 2012 14:28:26 +0200 Message-Id: <1343305716-5178-9-git-send-email-afaerber@suse.de> In-Reply-To: <1343305716-5178-1-git-send-email-afaerber@suse.de> References: <1343305716-5178-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v4 08/18] ppce500_pci: QOM'ify e500 PCI host bridge List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mst@redhat.com, Alexander Graf , "open list:e500" , anthony@codemonkey.ws, Scott Wood , =?UTF-8?q?Andreas=20F=C3=A4rber?= , liwanp@linux.vnet.ibm.com Introduce type constant and cast macro. Avoid accessing parent fields directly. Signed-off-by: Andreas F=C3=A4rber --- hw/ppce500_pci.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) diff --git a/hw/ppce500_pci.c b/hw/ppce500_pci.c index 99748b3..e4f065a 100644 --- a/hw/ppce500_pci.c +++ b/hw/ppce500_pci.c @@ -72,8 +72,14 @@ struct pci_inbound { uint32_t piwar; }; =20 +#define TYPE_PPC_E500_PCI_HOST_BRIDGE "e500-pcihost" + +#define PPC_E500_PCI_HOST_BRIDGE(obj) \ + OBJECT_CHECK(PPCE500PCIState, (obj), TYPE_PPC_E500_PCI_HOST_BRIDGE) + struct PPCE500PCIState { PCIHostState pci_state; + struct pci_outbound pob[PPCE500_PCI_NR_POBS]; struct pci_inbound pib[PPCE500_PCI_NR_PIBS]; uint32_t gasket_time; @@ -310,17 +316,17 @@ static int e500_pcihost_initfn(SysBusDevice *dev) MemoryRegion *address_space_mem =3D get_system_memory(); MemoryRegion *address_space_io =3D get_system_io(); =20 - h =3D FROM_SYSBUS(PCIHostState, sysbus_from_qdev(dev)); - s =3D DO_UPCAST(PPCE500PCIState, pci_state, h); + h =3D FROM_SYSBUS(PCIHostState, dev); + s =3D PPC_E500_PCI_HOST_BRIDGE(dev); =20 for (i =3D 0; i < ARRAY_SIZE(s->irq); i++) { sysbus_init_irq(dev, &s->irq[i]); } =20 - b =3D pci_register_bus(&s->pci_state.busdev.qdev, NULL, mpc85xx_pci_= set_irq, + b =3D pci_register_bus(DEVICE(dev), NULL, mpc85xx_pci_set_irq, mpc85xx_pci_map_irq, s->irq, address_space_mem, address_space_io, PCI_DEVFN(0x11, 0), 4); - s->pci_state.bus =3D b; + h->bus =3D b; =20 pci_create_simple(b, 0, "e500-host-bridge"); =20 @@ -367,7 +373,7 @@ static void e500_pcihost_class_init(ObjectClass *klas= s, void *data) } =20 static const TypeInfo e500_pcihost_info =3D { - .name =3D "e500-pcihost", + .name =3D TYPE_PPC_E500_PCI_HOST_BRIDGE, .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(PPCE500PCIState), .class_init =3D e500_pcihost_class_init, --=20 1.7.7