aboutsummaryrefslogtreecommitdiff
path: root/hw/audio/cs4231a.c
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2013-06-06 16:40:02 +0200
committerAndreas Färber <afaerber@suse.de>2013-06-06 17:09:09 +0200
commita3dcca567a1d4a5c79fb9c8fe2d9a21a4a7cebd5 (patch)
treede594aeb445e32c8ddfe5f74ff7b7c8ed43dc96a /hw/audio/cs4231a.c
parent11c7549d836b3d3a4ccd903bbfdbdc942b9add52 (diff)
downloadqemu-a3dcca567a1d4a5c79fb9c8fe2d9a21a4a7cebd5.zip
qemu-a3dcca567a1d4a5c79fb9c8fe2d9a21a4a7cebd5.tar.gz
qemu-a3dcca567a1d4a5c79fb9c8fe2d9a21a4a7cebd5.tar.bz2
cs4231a: QOM'ify some more
Introduce type constant and cast macro. Replace reset hook with DeviceClass::reset callback. Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/audio/cs4231a.c')
-rw-r--r--hw/audio/cs4231a.c17
1 files 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,