summary refs log tree commit diff stats
path: root/hw/misc/max111x.c
diff options
context:
space:
mode:
authorPeter Crosthwaite <peter.crosthwaite@xilinx.com>2014-02-11 16:29:35 -0800
committerAndreas Färber <afaerber@suse.de>2014-03-12 20:13:02 +0100
commit7c77b654c5371e970bc3190afe8dc85bc4f2c8ff (patch)
tree876e01699ba66bbf16744bbae99b3dae65ca3621 /hw/misc/max111x.c
parent5ef4a1c304ef60224c29aa9f6d9c2ac0591d020a (diff)
downloadfocaccia-qemu-7c77b654c5371e970bc3190afe8dc85bc4f2c8ff.tar.gz
focaccia-qemu-7c77b654c5371e970bc3190afe8dc85bc4f2c8ff.zip
misc/max111x: QOM casting sweep
Define and use QOM cast macro. Removes some usages of legacy casting
systems.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
[AF: Rename parent field]
Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/misc/max111x.c')
-rw-r--r--hw/misc/max111x.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/hw/misc/max111x.c b/hw/misc/max111x.c
index 1b5da699b9..bba87c2ec5 100644
--- a/hw/misc/max111x.c
+++ b/hw/misc/max111x.c
@@ -13,7 +13,8 @@
 #include "hw/ssi.h"
 
 typedef struct {
-    SSISlave ssidev;
+    SSISlave parent_obj;
+
     qemu_irq interrupt;
     uint8_t tb1, rb2, rb3;
     int cycle;
@@ -24,6 +25,9 @@ typedef struct {
 
 #define TYPE_MAX_111X "max111x"
 
+#define MAX_111X(obj) \
+    OBJECT_CHECK(MAX111xState, (obj), TYPE_MAX_111X)
+
 #define TYPE_MAX_1110 "max1110"
 #define TYPE_MAX_1111 "max1111"
 
@@ -97,7 +101,7 @@ static void max111x_write(MAX111xState *s, uint32_t value)
 
 static uint32_t max111x_transfer(SSISlave *dev, uint32_t value)
 {
-    MAX111xState *s = FROM_SSI_SLAVE(MAX111xState, dev);
+    MAX111xState *s = MAX_111X(dev);
     max111x_write(s, value);
     return max111x_read(s);
 }
@@ -108,7 +112,7 @@ static const VMStateDescription vmstate_max111x = {
     .minimum_version_id = 1,
     .minimum_version_id_old = 1,
     .fields      = (VMStateField[]) {
-        VMSTATE_SSI_SLAVE(ssidev, MAX111xState),
+        VMSTATE_SSI_SLAVE(parent_obj, MAX111xState),
         VMSTATE_UINT8(tb1, MAX111xState),
         VMSTATE_UINT8(rb2, MAX111xState),
         VMSTATE_UINT8(rb3, MAX111xState),
@@ -123,7 +127,7 @@ static const VMStateDescription vmstate_max111x = {
 static int max111x_init(SSISlave *d, int inputs)
 {
     DeviceState *dev = DEVICE(d);
-    MAX111xState *s = FROM_SSI_SLAVE(MAX111xState, d);
+    MAX111xState *s = MAX_111X(dev);
 
     qdev_init_gpio_out(dev, &s->interrupt, 1);
 
@@ -155,7 +159,7 @@ static int max1111_init(SSISlave *dev)
 
 void max111x_set_input(DeviceState *dev, int line, uint8_t value)
 {
-    MAX111xState *s = FROM_SSI_SLAVE(MAX111xState, SSI_SLAVE_FROM_QDEV(dev));
+    MAX111xState *s = MAX_111X(dev);
     assert(line >= 0 && line < s->inputs);
     s->input[line] = value;
 }