From patchwork Sat Jun 22 08:50:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 253370 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 34A402C040C for ; Sat, 22 Jun 2013 18:53:53 +1000 (EST) Received: from localhost ([::1]:42435 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqJZv-0004As-3i for incoming@patchwork.ozlabs.org; Sat, 22 Jun 2013 04:53:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43459) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqJXy-00013U-Vk for qemu-devel@nongnu.org; Sat, 22 Jun 2013 04:51:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UqJXw-0003aM-8l for qemu-devel@nongnu.org; Sat, 22 Jun 2013 04:51:50 -0400 Received: from [222.73.24.84] (port=12713 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqJXv-0003ZE-Uy for qemu-devel@nongnu.org; Sat, 22 Jun 2013 04:51:48 -0400 X-IronPort-AV: E=Sophos;i="4.87,917,1363104000"; d="scan'208";a="7638488" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 22 Jun 2013 16:48:35 +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 r5M8pTYI002350; Sat, 22 Jun 2013 16:51:30 +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 2013062216502054-2388915 ; Sat, 22 Jun 2013 16:50:20 +0800 From: Hu Tao To: qemu-devel Date: Sat, 22 Jun 2013 16:50:22 +0800 Message-Id: <3d07fa9c99fef86c95bfc5319474daa3bf69bb9a.1371804804.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/06/22 16:50:20, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/06/22 16:50:21, Serialize complete at 2013/06/22 16:50:21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 222.73.24.84 Cc: Kevin Wolf , Peter Crosthwaite , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 10/26] pflash-cfi01: 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 and avoid DO_UPCAST(). Cc: Kevin Wolf Cc: Stefan Hajnoczi Signed-off-by: Hu Tao --- hw/block/pflash_cfi01.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index aa04a2e..cc27f92 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -60,6 +60,9 @@ do { \ #define DPRINTF(fmt, ...) do { } while (0) #endif +#define TYPE_CFI_PFLASH01 "cfi.pflash01" +#define CFI_PFLASH01(obj) OBJECT_CHECK(pflash_t, (obj), TYPE_CFI_PFLASH01) + struct pflash_t { SysBusDevice busdev; BlockDriverState *bs; @@ -565,7 +568,7 @@ static const MemoryRegionOps pflash_cfi01_ops_le = { static void pflash_cfi01_realize(DeviceState *dev, Error **err) { - pflash_t *pfl = DO_UPCAST(pflash_t, busdev.qdev, dev); + pflash_t *pfl = CFI_PFLASH01(dev); uint64_t total_len; int ret; @@ -717,7 +720,7 @@ static void pflash_cfi01_class_init(ObjectClass *klass, void *data) static const TypeInfo pflash_cfi01_info = { - .name = "cfi.pflash01", + .name = TYPE_CFI_PFLASH01, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(struct pflash_t), .class_init = pflash_cfi01_class_init, @@ -738,10 +741,7 @@ pflash_t *pflash_cfi01_register(hwaddr base, uint16_t id0, uint16_t id1, uint16_t id2, uint16_t id3, int be) { - DeviceState *dev = qdev_create(NULL, "cfi.pflash01"); - SysBusDevice *busdev = SYS_BUS_DEVICE(dev); - pflash_t *pfl = (pflash_t *)object_dynamic_cast(OBJECT(dev), - "cfi.pflash01"); + DeviceState *dev = qdev_create(NULL, TYPE_CFI_PFLASH01); if (bs && qdev_prop_set_drive(dev, "drive", bs)) { abort(); @@ -757,8 +757,8 @@ pflash_t *pflash_cfi01_register(hwaddr base, qdev_prop_set_string(dev, "name", name); qdev_init_nofail(dev); - sysbus_mmio_map(busdev, 0, base); - return pfl; + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); + return CFI_PFLASH01(dev); } MemoryRegion *pflash_cfi01_get_memory(pflash_t *fl)