From patchwork Mon Jul 29 03:50:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 262662 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3879D2C0118 for ; Mon, 29 Jul 2013 13:50:57 +1000 (EST) Received: from localhost ([::1]:41959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3eU2-00086u-VC for incoming@patchwork.ozlabs.org; Sun, 28 Jul 2013 23:50:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49238) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3eTX-00086h-Tb for qemu-devel@nongnu.org; Sun, 28 Jul 2013 23:50:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V3eTR-0004EY-TF for qemu-devel@nongnu.org; Sun, 28 Jul 2013 23:50:23 -0400 Received: from cantor2.suse.de ([195.135.220.15]:48009 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3eTR-0004ET-Jh for qemu-devel@nongnu.org; Sun, 28 Jul 2013 23:50:17 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D0F92A4EB7 for ; Mon, 29 Jul 2013 05:50:16 +0200 (CEST) Message-ID: <51F5E673.4080405@suse.de> Date: Mon, 29 Jul 2013 05:50:11 +0200 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= Organization: SUSE LINUX Products GmbH User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: qemu-devel@nongnu.org References: <1374932223-7490-1-git-send-email-afaerber@suse.de> <1374932223-7490-18-git-send-email-afaerber@suse.de> In-Reply-To: <1374932223-7490-18-git-send-email-afaerber@suse.de> X-Enigmail-Version: 1.6a1pre X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Subject: Re: [Qemu-devel] [PATCH qom-next for-1.6 17/20] pxa2xx_timer: QOM cast cleanup X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Am 27.07.2013 15:37, schrieb Andreas Färber: > Signed-off-by: Andreas Färber > --- > hw/timer/pxa2xx_timer.c | 38 +++++++++++++++++++++++++++----------- > 1 file changed, 27 insertions(+), 11 deletions(-) > > diff --git a/hw/timer/pxa2xx_timer.c b/hw/timer/pxa2xx_timer.c > index 4d28719..ff63fa6 100644 > --- a/hw/timer/pxa2xx_timer.c > +++ b/hw/timer/pxa2xx_timer.c > @@ -60,6 +60,10 @@ static int pxa2xx_timer4_freq[8] = { > [5 ... 7] = 0, > }; > > +#define TYPE_PXA2XX_TIMER "pxa2xx-timer" > +#define PXA2XX_TIMER(obj) \ > + OBJECT_CHECK(PXA2xxTimerInfo, (obj), TYPE_PXA2XX_TIMER) > + > typedef struct PXA2xxTimerInfo PXA2xxTimerInfo; > > typedef struct { > @@ -80,7 +84,8 @@ typedef struct { > } PXA2xxTimer4; > > struct PXA2xxTimerInfo { > - SysBusDevice busdev; > + SysBusDevice parent_obj; > + > MemoryRegion iomem; > uint32_t flags; > > @@ -429,10 +434,9 @@ static int pxa25x_timer_post_load(void *opaque, int version_id) > > static int pxa2xx_timer_init(SysBusDevice *dev) > { > + PXA2xxTimerInfo *s = PXA2XX_TIMER(dev); > int i; > - PXA2xxTimerInfo *s; > > - s = FROM_SYSBUS(PXA2xxTimerInfo, dev); > s->irq_enabled = 0; > s->oldclock = 0; > s->clock = 0; > @@ -527,18 +531,15 @@ static const VMStateDescription vmstate_pxa2xx_timer_regs = { > static Property pxa25x_timer_dev_properties[] = { > DEFINE_PROP_UINT32("freq", PXA2xxTimerInfo, freq, PXA25X_FREQ), > DEFINE_PROP_BIT("tm4", PXA2xxTimerInfo, flags, > - PXA2XX_TIMER_HAVE_TM4, false), > + PXA2XX_TIMER_HAVE_TM4, false), > DEFINE_PROP_END_OF_LIST(), > }; > > static void pxa25x_timer_dev_class_init(ObjectClass *klass, void *data) > { > DeviceClass *dc = DEVICE_CLASS(klass); > - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); > > - k->init = pxa2xx_timer_init; > dc->desc = "PXA25x timer"; > - dc->vmsd = &vmstate_pxa2xx_timer_regs; > dc->props = pxa25x_timer_dev_properties; > } > > @@ -552,18 +553,15 @@ static const TypeInfo pxa25x_timer_dev_info = { > static Property pxa27x_timer_dev_properties[] = { > DEFINE_PROP_UINT32("freq", PXA2xxTimerInfo, freq, PXA27X_FREQ), > DEFINE_PROP_BIT("tm4", PXA2xxTimerInfo, flags, > - PXA2XX_TIMER_HAVE_TM4, true), > + PXA2XX_TIMER_HAVE_TM4, true), > DEFINE_PROP_END_OF_LIST(), > }; > > static void pxa27x_timer_dev_class_init(ObjectClass *klass, void *data) > { > DeviceClass *dc = DEVICE_CLASS(klass); > - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); > > - k->init = pxa2xx_timer_init; > dc->desc = "PXA27x timer"; > - dc->vmsd = &vmstate_pxa2xx_timer_regs; > dc->props = pxa27x_timer_dev_properties; > } > > @@ -574,8 +572,26 @@ static const TypeInfo pxa27x_timer_dev_info = { > .class_init = pxa27x_timer_dev_class_init, > }; > > +static void pxa2xx_timer_class_init(ObjectClass *oc, void *data) > +{ > + DeviceClass *dc = DEVICE_CLASS(oc); > + SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(oc); > + > + sdc->init = pxa2xx_timer_init; > + dc->vmsd = &vmstate_pxa2xx_timer_regs; > +} > + > +static const TypeInfo pxa2xx_timer_type_info = { > + .name = TYPE_PXA2XX_TIMER, > + .parent = TYPE_SYS_BUS_DEVICE, > + .instance_size = sizeof(PXA2xxTimerInfo), > + .abstract = true, > + .class_init = pxa2xx_timer_class_init, > +}; > + > static void pxa2xx_timer_register_types(void) > { > + type_register_static(&pxa2xx_timer_type_info); > type_register_static(&pxa25x_timer_dev_info); > type_register_static(&pxa27x_timer_dev_info); > } Needs the following addition (and subject fix), found by qtests: }; @@ -567,7 +567,7 @@ static void pxa27x_timer_dev_class_init(ObjectClass *klass, void *data) static const TypeInfo pxa27x_timer_dev_info = { .name = "pxa27x-timer", - .parent = TYPE_SYS_BUS_DEVICE, + .parent = TYPE_PXA2XX_TIMER, .instance_size = sizeof(PXA2xxTimerInfo), .class_init = pxa27x_timer_dev_class_init, Andreas diff --git a/hw/timer/pxa2xx_timer.c b/hw/timer/pxa2xx_timer.c index ff63fa6..cdabccd 100644 --- a/hw/timer/pxa2xx_timer.c +++ b/hw/timer/pxa2xx_timer.c @@ -545,7 +545,7 @@ static void pxa25x_timer_dev_class_init(ObjectClass *klass, void *data) static const TypeInfo pxa25x_timer_dev_info = { .name = "pxa25x-timer", - .parent = TYPE_SYS_BUS_DEVICE, + .parent = TYPE_PXA2XX_TIMER, .instance_size = sizeof(PXA2xxTimerInfo), .class_init = pxa25x_timer_dev_class_init,