Patchwork [RFC,v1,1/4] xilinx.h: Dont qdev_create from ethernet_create()

login
register
mail settings
Submitter Peter Crosthwaite
Date Feb. 12, 2013, 1:17 a.m.
Message ID <974711325dcf4c4ab25f051eede2d04adcfa5f34.1360631576.git.peter.crosthwaite@xilinx.com>
Download mbox | patch
Permalink /patch/219714/
State New
Headers show

Comments

Peter Crosthwaite - Feb. 12, 2013, 1:17 a.m.
Pulled the qdev_create functionality out of xilinx_axiethernet_create() and
pushed it up to the petalogix_ml605_mmu machine model. This makes the ethernet
create+init process consistent with the AXI DMA. Renamed function to
xilinx_axiethernet_init accordingly.

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

 hw/petalogix_ml605_mmu.c |    6 ++++--
 hw/xilinx.h              |   13 +++----------
 2 files changed, 7 insertions(+), 12 deletions(-)

Patch

diff --git a/hw/petalogix_ml605_mmu.c b/hw/petalogix_ml605_mmu.c
index bdfc6ce..8fd55a0 100644
--- a/hw/petalogix_ml605_mmu.c
+++ b/hw/petalogix_ml605_mmu.c
@@ -129,14 +129,16 @@  petalogix_ml605_init(QEMUMachineInitArgs *args)
     xilinx_timer_create(TIMER_BASEADDR, irq[2], 0, 100 * 1000000);
 
     /* axi ethernet and dma initialization. */
+    qemu_check_nic_model(&nd_table[0], "xlnx.axi-ethernet");
+    eth0 = qdev_create(NULL, "xlnx.axi-ethernet");
     dma = qdev_create(NULL, "xlnx.axi-dma");
 
     /* FIXME: attach to the sysbus instead */
     object_property_add_child(container_get(qdev_get_machine(), "/unattached"),
                                   "xilinx-dma", OBJECT(dma), NULL);
 
-    eth0 = xilinx_axiethernet_create(&nd_table[0], STREAM_SLAVE(dma),
-                                     0x82780000, irq[3], 0x1000, 0x1000);
+    xilinx_axiethernet_init(eth0, &nd_table[0], STREAM_SLAVE(dma),
+                                   0x82780000, irq[3], 0x1000, 0x1000);
 
     xilinx_axiethernetdma_init(dma, STREAM_SLAVE(eth0),
                                0x84600000, irq[1], irq[0], 100 * 1000000);
diff --git a/hw/xilinx.h b/hw/xilinx.h
index 725f2f4..d255ca7 100644
--- a/hw/xilinx.h
+++ b/hw/xilinx.h
@@ -53,17 +53,12 @@  xilinx_ethlite_create(NICInfo *nd, hwaddr base, qemu_irq irq,
     return dev;
 }
 
-static inline DeviceState *
-xilinx_axiethernet_create(NICInfo *nd, StreamSlave *peer,
-                          hwaddr base, qemu_irq irq,
-                          int txmem, int rxmem)
+static inline void
+xilinx_axiethernet_init(DeviceState *dev, NICInfo *nd, StreamSlave *peer,
+                        hwaddr base, qemu_irq irq, int txmem, int rxmem)
 {
-    DeviceState *dev;
     Error *errp = NULL;
 
-    qemu_check_nic_model(nd, "xlnx.axi-ethernet");
-
-    dev = qdev_create(NULL, "xlnx.axi-ethernet");
     qdev_set_nic_properties(dev, nd);
     qdev_prop_set_uint32(dev, "rxmem", rxmem);
     qdev_prop_set_uint32(dev, "txmem", txmem);
@@ -73,8 +68,6 @@  xilinx_axiethernet_create(NICInfo *nd, StreamSlave *peer,
     qdev_init_nofail(dev);
     sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
     sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq);
-
-    return dev;
 }
 
 static inline void