From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58709) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1Pow-0003N7-6H for qemu-devel@nongnu.org; Mon, 22 Jul 2013 19:47:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1Poo-00041w-J6 for qemu-devel@nongnu.org; Mon, 22 Jul 2013 19:47:13 -0400 Received: from cantor2.suse.de ([195.135.220.15]:45843 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1Poo-000411-56 for qemu-devel@nongnu.org; Mon, 22 Jul 2013 19:47:06 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 23 Jul 2013 01:46:21 +0200 Message-Id: <1374536796-13983-41-git-send-email-afaerber@suse.de> In-Reply-To: <1374536796-13983-1-git-send-email-afaerber@suse.de> References: <1374536796-13983-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] [PULL 40/55] hpet: QOM'ify some more List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Hu Tao , =?UTF-8?q?Andreas=20F=C3=A4rber?= From: Hu Tao Introduce type constant, avoid FROM_SYSBUS(). Signed-off-by: Hu Tao [AF: Renamed parent field and renamed variable] Signed-off-by: Andreas F=C3=A4rber --- hw/timer/hpet.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 90bd584..228598f 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -42,6 +42,9 @@ =20 #define HPET_MSI_SUPPORT 0 =20 +#define TYPE_HPET "hpet" +#define HPET(obj) OBJECT_CHECK(HPETState, (obj), TYPE_HPET) + struct HPETState; typedef struct HPETTimer { /* timers */ uint8_t tn; /*timer number*/ @@ -59,7 +62,10 @@ typedef struct HPETTimer { /* timers */ } HPETTimer; =20 typedef struct HPETState { - SysBusDevice busdev; + /*< private >*/ + SysBusDevice parent_obj; + /*< public >*/ + MemoryRegion iomem; uint64_t hpet_offset; qemu_irq irqs[HPET_NUM_IRQ_ROUTES]; @@ -634,7 +640,8 @@ static const MemoryRegionOps hpet_ram_ops =3D { =20 static void hpet_reset(DeviceState *d) { - HPETState *s =3D FROM_SYSBUS(HPETState, SYS_BUS_DEVICE(d)); + HPETState *s =3D HPET(d); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(d); int i; =20 for (i =3D 0; i < s->num_timers; i++) { @@ -657,7 +664,7 @@ static void hpet_reset(DeviceState *d) s->hpet_offset =3D 0ULL; s->config =3D 0ULL; hpet_cfg.hpet[s->hpet_id].event_timer_block_id =3D (uint32_t)s->capa= bility; - hpet_cfg.hpet[s->hpet_id].address =3D SYS_BUS_DEVICE(d)->mmio[0].add= r; + hpet_cfg.hpet[s->hpet_id].address =3D sbd->mmio[0].addr; =20 /* to document that the RTC lowers its output on reset as well */ s->rtc_irq_level =3D 0; @@ -665,7 +672,7 @@ static void hpet_reset(DeviceState *d) =20 static void hpet_handle_legacy_irq(void *opaque, int n, int level) { - HPETState *s =3D FROM_SYSBUS(HPETState, opaque); + HPETState *s =3D HPET(opaque); =20 if (n =3D=3D HPET_LEGACY_PIT_INT) { if (!hpet_in_legacy_mode(s)) { @@ -681,7 +688,7 @@ static void hpet_handle_legacy_irq(void *opaque, int = n, int level) =20 static int hpet_init(SysBusDevice *dev) { - HPETState *s =3D FROM_SYSBUS(HPETState, dev); + HPETState *s =3D HPET(dev); int i; HPETTimer *timer; =20 @@ -746,7 +753,7 @@ static void hpet_device_class_init(ObjectClass *klass= , void *data) } =20 static const TypeInfo hpet_device_info =3D { - .name =3D "hpet", + .name =3D TYPE_HPET, .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(HPETState), .class_init =3D hpet_device_class_init, --=20 1.8.1.4