From patchwork Mon Jul 1 10:18:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 256075 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 C00492C00A7 for ; Mon, 1 Jul 2013 20:30:49 +1000 (EST) Received: from localhost ([::1]:35051 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtbNf-0000lg-JU for incoming@patchwork.ozlabs.org; Mon, 01 Jul 2013 06:30:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtbD7-0000EL-4y for qemu-devel@nongnu.org; Mon, 01 Jul 2013 06:19:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UtbD1-0001KF-TW for qemu-devel@nongnu.org; Mon, 01 Jul 2013 06:19:52 -0400 Received: from [222.73.24.84] (port=20227 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtbD1-0001Fv-H6 for qemu-devel@nongnu.org; Mon, 01 Jul 2013 06:19:47 -0400 X-IronPort-AV: E=Sophos;i="4.87,973,1363104000"; d="scan'208";a="7747773" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 01 Jul 2013 18:16:44 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r61AJcOk015552 for ; Mon, 1 Jul 2013 18:19:40 +0800 Received: from G08FNSTD100614.fnst.cn.fujitsu.com ([10.167.233.156]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013070118181415-2618451 ; Mon, 1 Jul 2013 18:18:14 +0800 From: Hu Tao To: qemu-devel Date: Mon, 1 Jul 2013 18:18:36 +0800 Message-Id: <0dbb52c45b5baf53abb336b7f972cdd2aadb3640.1372673778.git.hutao@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/07/01 18:18:14, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/07/01 18:18:16, Serialize complete at 2013/07/01 18:18:16 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 222.73.24.84 Subject: [Qemu-devel] [PATCH v2 20/26] hpet: QOM'ify some more 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 Introduce type constant, avoid FROM_SYSBUS(). Signed-off-by: Hu Tao --- hw/timer/hpet.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 95dd01d..af80e63 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -42,6 +42,9 @@ #define HPET_MSI_SUPPORT 0 +#define TYPE_HPET "hpet" +#define HPET(obj) OBJECT_CHECK(HPETState, (obj), TYPE_HPET) + struct HPETState; typedef struct HPETTimer { /* timers */ uint8_t tn; /*timer number*/ @@ -634,7 +637,8 @@ static const MemoryRegionOps hpet_ram_ops = { static void hpet_reset(DeviceState *d) { - HPETState *s = FROM_SYSBUS(HPETState, SYS_BUS_DEVICE(d)); + HPETState *s = HPET(d); + SysBusDevice *bus = SYS_BUS_DEVICE(d); int i; for (i = 0; i < s->num_timers; i++) { @@ -657,7 +661,7 @@ static void hpet_reset(DeviceState *d) s->hpet_offset = 0ULL; s->config = 0ULL; hpet_cfg.hpet[s->hpet_id].event_timer_block_id = (uint32_t)s->capability; - hpet_cfg.hpet[s->hpet_id].address = SYS_BUS_DEVICE(d)->mmio[0].addr; + hpet_cfg.hpet[s->hpet_id].address = bus->mmio[0].addr; /* to document that the RTC lowers its output on reset as well */ s->rtc_irq_level = 0; @@ -665,7 +669,7 @@ static void hpet_reset(DeviceState *d) static void hpet_handle_legacy_irq(void *opaque, int n, int level) { - HPETState *s = FROM_SYSBUS(HPETState, opaque); + HPETState *s = HPET(opaque); if (n == HPET_LEGACY_PIT_INT) { if (!hpet_in_legacy_mode(s)) { @@ -681,7 +685,7 @@ static void hpet_handle_legacy_irq(void *opaque, int n, int level) static int hpet_init(SysBusDevice *dev) { - HPETState *s = FROM_SYSBUS(HPETState, dev); + HPETState *s = HPET(dev); int i; HPETTimer *timer; @@ -746,7 +750,7 @@ static void hpet_device_class_init(ObjectClass *klass, void *data) } static const TypeInfo hpet_device_info = { - .name = "hpet", + .name = TYPE_HPET, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(HPETState), .class_init = hpet_device_class_init,