Patchwork [v6,06/16] xilinx_axidma: Defined and use type cast macro

login
register
mail settings
Submitter Peter Crosthwaite
Date April 16, 2013, 12:22 a.m.
Message ID <7964d1c629a03450b7f223773a76c0bcef94b06f.1366069170.git.peter.crosthwaite@xilinx.com>
Download mbox | patch
Permalink /patch/236784/
State New
Headers show

Comments

Peter Crosthwaite - April 16, 2013, 12:22 a.m.
From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

Standard QOM cast macro. Replaces usages of FROM_SYSBUS

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Acked-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---

 hw/dma/xilinx_axidma.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

Patch

diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
index 4dd8a6b..0b5bb44 100644
--- a/hw/dma/xilinx_axidma.c
+++ b/hw/dma/xilinx_axidma.c
@@ -32,6 +32,11 @@ 
 
 #define D(x)
 
+#define TYPE_XILINX_AXI_DMA "xlnx.axi-dma"
+
+#define XILINX_AXI_DMA(obj) \
+     OBJECT_CHECK(XilinxAXIDMA, (obj), TYPE_XILINX_AXI_DMA)
+
 #define R_DMACR             (0x00 / 4)
 #define R_DMASR             (0x04 / 4)
 #define R_CURDESC           (0x08 / 4)
@@ -355,7 +360,7 @@  static void stream_process_s2mem(struct Stream *s,
 static void
 axidma_push(StreamSlave *obj, unsigned char *buf, size_t len, uint32_t *app)
 {
-    XilinxAXIDMA *d = FROM_SYSBUS(typeof(*d), SYS_BUS_DEVICE(obj));
+    XilinxAXIDMA *d = XILINX_AXI_DMA(obj);
     struct Stream *s = &d->streams[1];
 
     if (!app) {
@@ -461,7 +466,7 @@  static const MemoryRegionOps axidma_ops = {
 
 static int xilinx_axidma_init(SysBusDevice *dev)
 {
-    XilinxAXIDMA *s = FROM_SYSBUS(typeof(*s), dev);
+    XilinxAXIDMA *s = XILINX_AXI_DMA(dev);
     int i;
 
     sysbus_init_irq(dev, &s->streams[0].irq);
@@ -483,7 +488,7 @@  static int xilinx_axidma_init(SysBusDevice *dev)
 
 static void xilinx_axidma_initfn(Object *obj)
 {
-    XilinxAXIDMA *s = FROM_SYSBUS(typeof(*s), SYS_BUS_DEVICE(obj));
+    XilinxAXIDMA *s = XILINX_AXI_DMA(obj);
 
     object_property_add_link(obj, "axistream-connected", TYPE_STREAM_SLAVE,
                              (Object **) &s->tx_dev, NULL);
@@ -506,7 +511,7 @@  static void axidma_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo axidma_info = {
-    .name          = "xlnx.axi-dma",
+    .name          = TYPE_XILINX_AXI_DMA,
     .parent        = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(XilinxAXIDMA),
     .class_init    = axidma_class_init,