Patchwork [v2,2/8] xilinx_axienet: Defined and use type cast macro

login
register
mail settings
Submitter Peter Crosthwaite
Date Feb. 25, 2013, 8:50 a.m.
Message ID <3fa68421e9fedcac5f04cedeeff734b899d0fec9.1361782087.git.peter.crosthwaite@xilinx.com>
Download mbox | patch
Permalink /patch/222864/
State New
Headers show

Comments

Peter Crosthwaite - Feb. 25, 2013, 8:50 a.m.
Standard QOM cast macro. Replaces usages of FROM_SYSBUS

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---

 hw/xilinx_axienet.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
Andreas Färber - Feb. 25, 2013, 12:41 p.m.
Am 25.02.2013 09:50, schrieb Peter Crosthwaite:
> Standard QOM cast macro. Replaces usages of FROM_SYSBUS
> 
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

Reviewed-by: Andreas Färber <afaerber@suse.de>

Andreas

Patch

diff --git a/hw/xilinx_axienet.c b/hw/xilinx_axienet.c
index 4042e1a..7b50682 100644
--- a/hw/xilinx_axienet.c
+++ b/hw/xilinx_axienet.c
@@ -31,6 +31,11 @@ 
 
 #define DPHY(x)
 
+#define TYPE_XILINX_AXI_ENET "xlnx.axi-ethernet"
+
+#define XILINX_AXI_ENET(obj) \
+     OBJECT_CHECK(XilinxAXIEnet, (obj), TYPE_XILINX_AXI_ENET)
+
 /* Advertisement control register. */
 #define ADVERTISE_10HALF        0x0020  /* Try for 10mbps half-duplex  */
 #define ADVERTISE_10FULL        0x0040  /* Try for 10mbps full-duplex  */
@@ -845,7 +850,7 @@  static NetClientInfo net_xilinx_enet_info = {
 
 static int xilinx_enet_init(SysBusDevice *dev)
 {
-    XilinxAXIEnet *s = FROM_SYSBUS(typeof(*s), dev);
+    XilinxAXIEnet *s = XILINX_AXI_ENET(dev);
 
     sysbus_init_irq(dev, &s->irq);
 
@@ -870,7 +875,7 @@  static int xilinx_enet_init(SysBusDevice *dev)
 
 static void xilinx_enet_initfn(Object *obj)
 {
-    XilinxAXIEnet *s = FROM_SYSBUS(typeof(*s), SYS_BUS_DEVICE(obj));
+    XilinxAXIEnet *s = XILINX_AXI_ENET(obj);
     Error *errp = NULL;
 
     object_property_add_link(obj, "axistream-connected", TYPE_STREAM_SLAVE,
@@ -898,7 +903,7 @@  static void xilinx_enet_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo xilinx_enet_info = {
-    .name          = "xlnx.axi-ethernet",
+    .name          = TYPE_XILINX_AXI_ENET,
     .parent        = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(XilinxAXIEnet),
     .class_init    = xilinx_enet_class_init,