From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmTEz-00008X-2y for qemu-devel@nongnu.org; Wed, 04 Jul 2012 13:19:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SmTEs-0004UH-9B for qemu-devel@nongnu.org; Wed, 04 Jul 2012 13:19:48 -0400 Received: from cantor2.suse.de ([195.135.220.15]:47780 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmTEr-0004Ty-WB for qemu-devel@nongnu.org; Wed, 04 Jul 2012 13:19:42 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 4 Jul 2012 19:19:21 +0200 Message-Id: <1341422373-13614-3-git-send-email-afaerber@suse.de> In-Reply-To: <1341422373-13614-1-git-send-email-afaerber@suse.de> References: <1341422373-13614-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 v3 02/14] alpha_typhoon: QOM'ify Typhoon PCI host bridge List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, jbaron@redhat.com, =?UTF-8?q?Andreas=20F=C3=A4rber?= , anthony@codemonkey.ws, mst@redhat.com Introduce type constant and cast macro. Don't access DeviceState indirectly through parent fields. Signed-off-by: Andreas F=C3=A4rber --- hw/alpha_typhoon.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/hw/alpha_typhoon.c b/hw/alpha_typhoon.c index cc63737..06e84a1 100644 --- a/hw/alpha_typhoon.c +++ b/hw/alpha_typhoon.c @@ -15,6 +15,8 @@ #include "exec-memory.h" =20 =20 +#define TYPE_TYPHOON_PCI_HOST_BRIDGE "typhoon-pcihost" + typedef struct TyphoonCchip { MemoryRegion region; uint64_t misc; @@ -40,8 +42,12 @@ typedef struct TyphoonPchip { TyphoonWindow win[4]; } TyphoonPchip; =20 +#define TYPHOON_PCI_HOST_BRIDGE(obj) \ + OBJECT_CHECK(TyphoonState, (obj), TYPE_TYPHOON_PCI_HOST_BRIDGE) + typedef struct TyphoonState { PCIHostState host; + TyphoonCchip cchip; TyphoonPchip pchip; MemoryRegion dchip_region; @@ -700,16 +706,14 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **= isa_bus, MemoryRegion *addr_space =3D get_system_memory(); MemoryRegion *addr_space_io =3D get_system_io(); DeviceState *dev; - PCIHostState *p; TyphoonState *s; PCIBus *b; int i; =20 - dev =3D qdev_create(NULL, "typhoon-pcihost"); + dev =3D qdev_create(NULL, TYPE_TYPHOON_PCI_HOST_BRIDGE); qdev_init_nofail(dev); =20 - p =3D FROM_SYSBUS(PCIHostState, sysbus_from_qdev(dev)); - s =3D container_of(p, TyphoonState, host); + s =3D TYPHOON_PCI_HOST_BRIDGE(dev); =20 /* Remember the CPUs so that we can deliver interrupts to them. */ for (i =3D 0; i < 4; i++) { @@ -763,7 +767,7 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **is= a_bus, memory_region_add_subregion(addr_space, 0x801fc000000ULL, &s->pchip.reg_io); =20 - b =3D pci_register_bus(&s->host.busdev.qdev, "pci", + b =3D pci_register_bus(dev, "pci", typhoon_set_irq, sys_map_irq, s, &s->pchip.reg_mem, addr_space_io, 0, 64); s->host.bus =3D b; @@ -818,7 +822,7 @@ static void typhoon_pcihost_class_init(ObjectClass *k= lass, void *data) } =20 static const TypeInfo typhoon_pcihost_info =3D { - .name =3D "typhoon-pcihost", + .name =3D TYPE_TYPHOON_PCI_HOST_BRIDGE, .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(TyphoonState), .class_init =3D typhoon_pcihost_class_init, --=20 1.7.7