aboutsummaryrefslogtreecommitdiff
path: root/hw/input/lm832x.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-02-20 13:05:47 +0000
committerPeter Maydell <peter.maydell@linaro.org>2014-02-20 13:05:48 +0000
commit61e8a923646903d76a6d952019716b417d42eedc (patch)
tree038e4c1921d45b2fe5d650a8fb476bb8169a1544 /hw/input/lm832x.c
parent4c0c9bbe78901a706497a8fa1a27935bafc20cf7 (diff)
parent91f32b0c92fb18a403e48d3c8ffc14422a0c1ca5 (diff)
Merge remote-tracking branch 'remotes/afaerber/tags/qom-devices-for-peter' into staging
QOM infrastructure fixes and device conversions * QTest cleanups and test cases for PCI NICs * NAND fix for "info qtree" * Cleanup and extension of QOM machine tests * IndustryPack test cases and conversion to QOM realize * I2C cleanups * Cleanups of legacy qdev properties # gpg: Signature made Mon 17 Feb 2014 22:15:37 GMT using RSA key ID 3E7E013F # gpg: Good signature from "Andreas Färber <afaerber@suse.de>" # gpg: aka "Andreas Färber <afaerber@suse.com>" * remotes/afaerber/tags/qom-devices-for-peter: (49 commits) qtest: Include system headers before user headers qapi: Refine human printing of sizes qdev: Use QAPI type names for properties qdev: Add enum property types to QAPI schema block: Handle "rechs" and "large" translation options qdev: Remove hex8/32/64 property types qdev: Remove most legacy printers qdev: Use human mode in "info qtree" qapi: Add human mode to StringOutputVisitor qdev: Inline qdev_prop_parse() qdev: Legacy properties are just strings qdev: Legacy properties are now read-only qdev: Remove legacy parsers for hex8/32/64 qdev: Sizes are now parsed by StringInputVisitor qapi: Add size parser to StringInputVisitor qtest: Don't segfault with invalid -qtest option ipack: Move IndustryPack out of hw/char/ ipoctal232: QOM parent field cleanup ipack: QOM parent field cleanup for IPackDevice ipack: QOM parent field cleanup for IPackBus ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/input/lm832x.c')
-rw-r--r--hw/input/lm832x.c22
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,