From patchwork Mon Jul 29 19:17:53 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: 263083 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 7DC972C00E5 for ; Tue, 30 Jul 2013 08:29:22 +1000 (EST) Received: from localhost ([::1]:60465 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3t2Z-0005LP-P3 for incoming@patchwork.ozlabs.org; Mon, 29 Jul 2013 15:23:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3t05-000231-RG for qemu-devel@nongnu.org; Mon, 29 Jul 2013 15:21:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V3t00-0002CQ-AZ for qemu-devel@nongnu.org; Mon, 29 Jul 2013 15:20:57 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53228 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3t00-0002CH-41 for qemu-devel@nongnu.org; Mon, 29 Jul 2013 15:20:52 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id AE913A52BF; Mon, 29 Jul 2013 21:20:51 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Mon, 29 Jul 2013 21:17:53 +0200 Message-Id: <1375125630-24869-17-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1375125630-24869-1-git-send-email-afaerber@suse.de> References: <1375125630-24869-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: "Vassili Karpov \(malc\)" , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PULL 016/173] cs4231: 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 Introduce a type constant, use QOM casts and rename the parent field. Reviewed-by: Hu Tao Signed-off-by: Andreas Färber --- hw/audio/cs4231.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/audio/cs4231.c b/hw/audio/cs4231.c index fabe9e6..d19195a 100644 --- a/hw/audio/cs4231.c +++ b/hw/audio/cs4231.c @@ -33,8 +33,13 @@ #define CS_DREGS 32 #define CS_MAXDREG (CS_DREGS - 1) +#define TYPE_CS4231 "SUNW,CS4231" +#define CS4231(obj) \ + OBJECT_CHECK(CSState, (obj), TYPE_CS4231) + typedef struct CSState { - SysBusDevice busdev; + SysBusDevice parent_obj; + MemoryRegion iomem; qemu_irq irq; uint32_t regs[CS_REGS]; @@ -47,7 +52,7 @@ typedef struct CSState { static void cs_reset(DeviceState *d) { - CSState *s = container_of(d, CSState, busdev.qdev); + CSState *s = CS4231(d); memset(s->regs, 0, CS_REGS * 4); memset(s->dregs, 0, CS_DREGS); @@ -111,7 +116,7 @@ static void cs_mem_write(void *opaque, hwaddr addr, break; case 4: if (val & 1) { - cs_reset(&s->busdev.qdev); + cs_reset(DEVICE(s)); } val &= 0x7f; s->regs[saddr] = val; @@ -142,7 +147,7 @@ static const VMStateDescription vmstate_cs4231 = { static int cs4231_init1(SysBusDevice *dev) { - CSState *s = FROM_SYSBUS(CSState, dev); + CSState *s = CS4231(dev); memory_region_init_io(&s->iomem, OBJECT(s), &cs_mem_ops, s, "cs4321", CS_SIZE); @@ -168,7 +173,7 @@ static void cs4231_class_init(ObjectClass *klass, void *data) } static const TypeInfo cs4231_info = { - .name = "SUNW,CS4231", + .name = TYPE_CS4231, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(CSState), .class_init = cs4231_class_init,