aboutsummaryrefslogtreecommitdiff
path: root/hw/arm
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2013-12-19 21:51:29 +0100
committerAndreas Färber <afaerber@suse.de>2014-02-14 16:22:32 +0100
commit70b51690328872e0903e0615f32f05678f6b53cf (patch)
treeec57d6b127103a9b5639bc1f752c249a15446f12 /hw/arm
parent96dca6b9a964b96c3ce72449333ff3bdd4ce85f7 (diff)
downloadqemu-70b51690328872e0903e0615f32f05678f6b53cf.zip
qemu-70b51690328872e0903e0615f32f05678f6b53cf.tar.gz
qemu-70b51690328872e0903e0615f32f05678f6b53cf.tar.bz2
tosa: QOM'ify DAC
Replace usages of FROM_I2C_SLAVE() with QOM cast macro. Rename parent field. Use type constant in tosa_tg_init(). Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/arm')
-rw-r--r--hw/arm/tosa.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
index dd224d3..2069f55 100644
--- a/hw/arm/tosa.c
+++ b/hw/arm/tosa.c
@@ -132,15 +132,20 @@ static int tosa_ssp_init(SSISlave *dev)
return 0;
}
+#define TYPE_TOSA_DAC "tosa_dac"
+#define TOSA_DAC(obj) OBJECT_CHECK(TosaDACState, (obj), TYPE_TOSA_DAC)
+
typedef struct {
- I2CSlave i2c;
+ I2CSlave parent_obj;
+
int len;
char buf[3];
} TosaDACState;
static int tosa_dac_send(I2CSlave *i2c, uint8_t data)
{
- TosaDACState *s = FROM_I2C_SLAVE(TosaDACState, i2c);
+ TosaDACState *s = TOSA_DAC(i2c);
+
s->buf[s->len] = data;
if (s->len ++ > 2) {
#ifdef VERBOSE
@@ -159,7 +164,8 @@ static int tosa_dac_send(I2CSlave *i2c, uint8_t data)
static void tosa_dac_event(I2CSlave *i2c, enum i2c_event event)
{
- TosaDACState *s = FROM_I2C_SLAVE(TosaDACState, i2c);
+ TosaDACState *s = TOSA_DAC(i2c);
+
s->len = 0;
switch (event) {
case I2C_START_SEND:
@@ -195,7 +201,7 @@ static int tosa_dac_init(I2CSlave *i2c)
static void tosa_tg_init(PXA2xxState *cpu)
{
I2CBus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
- i2c_create_slave(bus, "tosa_dac", DAC_BASE);
+ i2c_create_slave(bus, TYPE_TOSA_DAC, DAC_BASE);
ssi_create_slave(cpu->ssp[1], "tosa-ssp");
}
@@ -271,7 +277,7 @@ static void tosa_dac_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo tosa_dac_info = {
- .name = "tosa_dac",
+ .name = TYPE_TOSA_DAC,
.parent = TYPE_I2C_SLAVE,
.instance_size = sizeof(TosaDACState),
.class_init = tosa_dac_class_init,