From patchwork Mon Jul 1 10:18:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 256089 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 C3A642C0040 for ; Mon, 1 Jul 2013 21:07:10 +1000 (EST) Received: from localhost ([::1]:55474 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtbLC-0004vH-Tv for incoming@patchwork.ozlabs.org; Mon, 01 Jul 2013 06:28:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtbD4-00008g-1W for qemu-devel@nongnu.org; Mon, 01 Jul 2013 06:19:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UtbD0-0001JL-Lf for qemu-devel@nongnu.org; Mon, 01 Jul 2013 06:19:49 -0400 Received: from [222.73.24.84] (port=3548 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtbD0-0001H6-82 for qemu-devel@nongnu.org; Mon, 01 Jul 2013 06:19:46 -0400 X-IronPort-AV: E=Sophos;i="4.87,973,1363104000"; d="scan'208";a="7747768" 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 r61AJdK7015573 for ; Mon, 1 Jul 2013 18:19:39 +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 2013070118181408-2618447 ; Mon, 1 Jul 2013 18:18:14 +0800 From: Hu Tao To: qemu-devel Date: Mon, 1 Jul 2013 18:18:32 +0800 Message-Id: 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 16/26] fwcfg: 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 Use type constant if possible and avoid DO_UPCAST(). Signed-off-by: Hu Tao --- hw/nvram/fw_cfg.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 3c255ce..c8722c2 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -35,6 +35,7 @@ #define TYPE_FW_CFG "fw_cfg" #define FW_CFG_NAME "fw_cfg" #define FW_CFG_PATH "/machine/" FW_CFG_NAME +#define FW_CFG(obj) OBJECT_CHECK(FWCfgState, (obj), TYPE_FW_CFG) typedef struct FWCfgEntry { uint32_t len; @@ -326,7 +327,7 @@ static const MemoryRegionOps fw_cfg_comb_mem_ops = { static void fw_cfg_reset(DeviceState *d) { - FWCfgState *s = DO_UPCAST(FWCfgState, busdev.qdev, d); + FWCfgState *s = FW_CFG(d); fw_cfg_select(s, 0); } @@ -489,12 +490,12 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port, SysBusDevice *d; FWCfgState *s; - dev = qdev_create(NULL, "fw_cfg"); + dev = qdev_create(NULL, TYPE_FW_CFG); qdev_prop_set_uint32(dev, "ctl_iobase", ctl_port); qdev_prop_set_uint32(dev, "data_iobase", data_port); d = SYS_BUS_DEVICE(dev); - s = DO_UPCAST(FWCfgState, busdev.qdev, dev); + s = FW_CFG(dev); assert(!object_resolve_path(FW_CFG_PATH, NULL)); @@ -524,7 +525,7 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port, static int fw_cfg_init1(SysBusDevice *dev) { - FWCfgState *s = FROM_SYSBUS(FWCfgState, dev); + FWCfgState *s = FW_CFG(dev); memory_region_init_io(&s->ctl_iomem, &fw_cfg_ctl_mem_ops, s, "fwcfg.ctl", FW_CFG_SIZE); @@ -557,8 +558,7 @@ static Property fw_cfg_properties[] = { FWCfgState *fw_cfg_find(void) { - return OBJECT_CHECK(FWCfgState, object_resolve_path(FW_CFG_PATH, NULL), - TYPE_FW_CFG); + return FW_CFG(object_resolve_path(FW_CFG_PATH, NULL)); } static void fw_cfg_class_init(ObjectClass *klass, void *data)