diff options
author | Andreas Färber <afaerber@suse.de> | 2013-12-19 22:30:16 +0100 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2014-02-14 16:22:32 +0100 |
commit | 933069eb534ad37db67eb5b550798170fccbc64c (patch) | |
tree | 1d5a8ee9c557f21313c6088a09d78dd1f61084f1 /hw | |
parent | b8bcf811bff0a5b9fb1e8663359d3cc175d93717 (diff) |
lm832x: QOM'ify
Replace usages of FROM_I2C_SLAVE() and direct parent field accesses with
QOM cast macro. Rename parent field.
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/input/lm832x.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/hw/input/lm832x.c b/hw/input/lm832x.c index f583cf0279..4ae1cd9c80 100644 --- a/hw/input/lm832x.c +++ b/hw/input/lm832x.c @@ -23,8 +23,12 @@ #include "qemu/timer.h" #include "ui/console.h" +#define TYPE_LM8323 "lm8323" +#define LM8323(obj) OBJECT_CHECK(LM823KbdState, (obj), TYPE_LM8323) + typedef struct { - I2CSlave i2c; + I2CSlave parent_obj; + uint8_t i2c_dir; uint8_t i2c_cycle; uint8_t reg; @@ -380,7 +384,7 @@ static void lm_kbd_write(LM823KbdState *s, int reg, int byte, uint8_t value) static void lm_i2c_event(I2CSlave *i2c, enum i2c_event event) { - LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, i2c); + LM823KbdState *s = LM8323(i2c); switch (event) { case I2C_START_RECV: @@ -396,14 +400,14 @@ static void lm_i2c_event(I2CSlave *i2c, enum i2c_event event) static int lm_i2c_rx(I2CSlave *i2c) { - LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, i2c); + LM823KbdState *s = LM8323(i2c); return lm_kbd_read(s, s->reg, s->i2c_cycle ++); } static int lm_i2c_tx(I2CSlave *i2c, uint8_t data) { - LM823KbdState *s = (LM823KbdState *) i2c; + LM823KbdState *s = LM8323(i2c); if (!s->i2c_cycle) s->reg = data; @@ -431,7 +435,7 @@ static const VMStateDescription vmstate_lm_kbd = { .minimum_version_id_old = 0, .post_load = lm_kbd_post_load, .fields = (VMStateField []) { - VMSTATE_I2C_SLAVE(i2c, LM823KbdState), + VMSTATE_I2C_SLAVE(parent_obj, LM823KbdState), VMSTATE_UINT8(i2c_dir, LM823KbdState), VMSTATE_UINT8(i2c_cycle, LM823KbdState), VMSTATE_UINT8(reg, LM823KbdState), @@ -460,13 +464,13 @@ static const VMStateDescription vmstate_lm_kbd = { static int lm8323_init(I2CSlave *i2c) { - LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, i2c); + LM823KbdState *s = LM8323(i2c); s->model = 0x8323; s->pwm.tm[0] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm0_tick, s); s->pwm.tm[1] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm1_tick, s); s->pwm.tm[2] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm2_tick, s); - qdev_init_gpio_out(&i2c->qdev, &s->nirq, 1); + qdev_init_gpio_out(DEVICE(i2c), &s->nirq, 1); lm_kbd_reset(s); @@ -476,7 +480,7 @@ static int lm8323_init(I2CSlave *i2c) void lm832x_key_event(DeviceState *dev, int key, int state) { - LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, I2C_SLAVE(dev)); + LM823KbdState *s = LM8323(dev); if ((s->status & INT_ERROR) && (s->error & ERR_FIFOOVR)) return; @@ -507,7 +511,7 @@ static void lm8323_class_init(ObjectClass *klass, void *data) } static const TypeInfo lm8323_info = { - .name = "lm8323", + .name = TYPE_LM8323, .parent = TYPE_I2C_SLAVE, .instance_size = sizeof(LM823KbdState), .class_init = lm8323_class_init, |