From patchwork Fri Jun 7 12:58:10 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: 249704 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 783642C0095 for ; Fri, 7 Jun 2013 23:02:29 +1000 (EST) Received: from localhost ([::1]:46159 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkwJH-0006N4-Hh for incoming@patchwork.ozlabs.org; Fri, 07 Jun 2013 09:02:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkwFR-0000xb-Ff for qemu-devel@nongnu.org; Fri, 07 Jun 2013 08:58:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkwFP-00084e-P7 for qemu-devel@nongnu.org; Fri, 07 Jun 2013 08:58:29 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53769 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkwFP-000842-Fq for qemu-devel@nongnu.org; Fri, 07 Jun 2013 08:58:27 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 68CCDA5554; Fri, 7 Jun 2013 14:58:26 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Fri, 7 Jun 2013 14:58:10 +0200 Message-Id: <1370609900-21998-3-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1370609900-21998-1-git-send-email-afaerber@suse.de> References: <1370609900-21998-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?= , anthony@codemonkey.ws Subject: [Qemu-devel] [PATCH v2 02/12] cs4231a: 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 cast macro. Replace reset hook with DeviceClass::reset callback. Signed-off-by: Andreas Färber --- hw/audio/cs4231a.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c index cc605e5..d3ce739 100644 --- a/hw/audio/cs4231a.c +++ b/hw/audio/cs4231a.c @@ -56,6 +56,9 @@ static struct { #define CS_REGS 16 #define CS_DREGS 32 +#define TYPE_CS4231A "cs4231a" +#define CS4231A(obj) OBJECT_CHECK (CSState, (obj), TYPE_CS4231A) + typedef struct CSState { ISADevice dev; QEMUSoundCard card; @@ -208,9 +211,9 @@ static int16_t ALawDecompressTable[256] = 944, 912, 1008, 976, 816, 784, 880, 848 }; -static void cs_reset (void *opaque) +static void cs4231a_reset (DeviceState *dev) { - CSState *s = opaque; + CSState *s = CS4231A (dev); s->regs[Index_Address] = 0x40; s->regs[Index_Data] = 0x00; @@ -643,7 +646,7 @@ static const MemoryRegionOps cs_ioport_ops = { static int cs4231a_initfn (ISADevice *dev) { - CSState *s = DO_UPCAST (CSState, dev, dev); + CSState *s = CS4231A (dev); isa_init_irq (dev, &s->pic, s->irq); @@ -652,16 +655,13 @@ static int cs4231a_initfn (ISADevice *dev) DMA_register_channel (s->dma, cs_dma_read, s); - qemu_register_reset (cs_reset, s); - cs_reset (s); - AUD_register_card ("cs4231a", &s->card); return 0; } static int cs4231a_init (ISABus *bus) { - isa_create_simple (bus, "cs4231a"); + isa_create_simple (bus, TYPE_CS4231A); return 0; } @@ -677,13 +677,14 @@ static void cs4231a_class_initfn (ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS (klass); ISADeviceClass *ic = ISA_DEVICE_CLASS (klass); ic->init = cs4231a_initfn; + dc->reset = cs4231a_reset; dc->desc = "Crystal Semiconductor CS4231A"; dc->vmsd = &vmstate_cs4231a; dc->props = cs4231a_properties; } static const TypeInfo cs4231a_info = { - .name = "cs4231a", + .name = TYPE_CS4231A, .parent = TYPE_ISA_DEVICE, .instance_size = sizeof (CSState), .class_init = cs4231a_class_initfn,