From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1SZb-00086L-DK for qemu-devel@nongnu.org; Mon, 22 Jul 2013 22:43:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1SZa-0000qz-Dh for qemu-devel@nongnu.org; Mon, 22 Jul 2013 22:43:35 -0400 Received: from cantor2.suse.de ([195.135.220.15]:49451 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1SZa-0000qj-4O for qemu-devel@nongnu.org; Mon, 22 Jul 2013 22:43:34 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 23 Jul 2013 04:43:09 +0200 Message-Id: <1374547404-11700-2-git-send-email-afaerber@suse.de> In-Reply-To: <1374547404-11700-1-git-send-email-afaerber@suse.de> References: <1374547404-11700-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 v2 01/16] cpu/a9mpcore: QOM casting cleanup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Paul Brook From: Andreas F=C3=A4rber Introduce type constant and cast macro and enforce its use by renaming A9MPPrivState::busdev field to parent_obj. Reviewed-by: Peter Crosthwaite Signed-off-by: Andreas F=C3=A4rber --- hw/cpu/a9mpcore.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/cpu/a9mpcore.c b/hw/cpu/a9mpcore.c index 6c00a59..3e675e3 100644 --- a/hw/cpu/a9mpcore.c +++ b/hw/cpu/a9mpcore.c @@ -10,8 +10,15 @@ =20 #include "hw/sysbus.h" =20 +#define TYPE_A9MPCORE_PRIV "a9mpcore_priv" +#define A9MPCORE_PRIV(obj) \ + OBJECT_CHECK(A9MPPrivState, (obj), TYPE_A9MPCORE_PRIV) + typedef struct A9MPPrivState { - SysBusDevice busdev; + /*< private >*/ + SysBusDevice parent_obj; + /*< public >*/ + uint32_t num_cpu; MemoryRegion container; DeviceState *mptimer; @@ -29,7 +36,7 @@ static void a9mp_priv_set_irq(void *opaque, int irq, in= t level) =20 static int a9mp_priv_init(SysBusDevice *dev) { - A9MPPrivState *s =3D FROM_SYSBUS(A9MPPrivState, dev); + A9MPPrivState *s =3D A9MPCORE_PRIV(dev); SysBusDevice *timerbusdev, *wdtbusdev, *gicbusdev, *scubusdev; int i; =20 @@ -43,7 +50,7 @@ static int a9mp_priv_init(SysBusDevice *dev) sysbus_pass_irq(dev, gicbusdev); =20 /* Pass through inbound GPIO lines to the GIC */ - qdev_init_gpio_in(&s->busdev.qdev, a9mp_priv_set_irq, s->num_irq - 3= 2); + qdev_init_gpio_in(DEVICE(dev), a9mp_priv_set_irq, s->num_irq - 32); =20 s->scu =3D qdev_create(NULL, "a9-scu"); qdev_prop_set_uint32(s->scu, "num-cpu", s->num_cpu); @@ -124,7 +131,7 @@ static void a9mp_priv_class_init(ObjectClass *klass, = void *data) } =20 static const TypeInfo a9mp_priv_info =3D { - .name =3D "a9mpcore_priv", + .name =3D TYPE_A9MPCORE_PRIV, .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(A9MPPrivState), .class_init =3D a9mp_priv_class_init, --=20 1.8.1.4