[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 22/33] etraxfs: remove PROP_PTR usage
From: |
Marc-André Lureau |
Subject: |
[PATCH v3 22/33] etraxfs: remove PROP_PTR usage |
Date: |
Wed, 23 Oct 2019 19:31:43 +0200 |
etraxfs_dma_client are not Object, so can't be exposed to user with
QOM path. Let's remove property usage and move the constructor to the
.c unit, simplifying some code on the way.
Signed-off-by: Marc-André Lureau <address@hidden>
---
hw/net/etraxfs_eth.c | 44 +++++++++++++++++++++++++++++----------
include/hw/cris/etraxfs.h | 20 +++---------------
2 files changed, 36 insertions(+), 28 deletions(-)
diff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c
index 4cfbf1135a..f30d963487 100644
--- a/hw/net/etraxfs_eth.c
+++ b/hw/net/etraxfs_eth.c
@@ -338,14 +338,8 @@ typedef struct ETRAXFSEthState
uint8_t macaddr[2][6];
uint32_t regs[FS_ETH_MAX_REGS];
- union {
- void *vdma_out;
- struct etraxfs_dma_client *dma_out;
- };
- union {
- void *vdma_in;
- struct etraxfs_dma_client *dma_in;
- };
+ struct etraxfs_dma_client *dma_out;
+ struct etraxfs_dma_client *dma_in;
/* MDIO bus. */
struct qemu_mdio mdio_bus;
@@ -635,8 +629,6 @@ static void etraxfs_eth_realize(DeviceState *dev, Error
**errp)
static Property etraxfs_eth_properties[] = {
DEFINE_PROP_UINT32("phyaddr", ETRAXFSEthState, phyaddr, 1),
- DEFINE_PROP_PTR("dma_out", ETRAXFSEthState, vdma_out),
- DEFINE_PROP_PTR("dma_in", ETRAXFSEthState, vdma_in),
DEFINE_NIC_PROPERTIES(ETRAXFSEthState, conf),
DEFINE_PROP_END_OF_LIST(),
};
@@ -648,10 +640,40 @@ static void etraxfs_eth_class_init(ObjectClass *klass,
void *data)
dc->realize = etraxfs_eth_realize;
dc->reset = etraxfs_eth_reset;
dc->props = etraxfs_eth_properties;
- /* Reason: pointer properties "dma_out", "dma_in" */
+ /* Reason: dma_out, dma_in are not user settable */
dc->user_creatable = false;
}
+
+/* Instantiate an ETRAXFS Ethernet MAC. */
+DeviceState *
+etraxfs_eth_init(NICInfo *nd, hwaddr base, int phyaddr,
+ struct etraxfs_dma_client *dma_out,
+ struct etraxfs_dma_client *dma_in)
+{
+ DeviceState *dev;
+ qemu_check_nic_model(nd, "fseth");
+
+ dev = qdev_create(NULL, "etraxfs-eth");
+ qdev_set_nic_properties(dev, nd);
+ qdev_prop_set_uint32(dev, "phyaddr", phyaddr);
+
+ /*
+ * TODO: QOM design, define a QOM interface for "I am an etraxfs
+ * DMA client" (which replaces the current 'struct
+ * etraxfs_dma_client' ad-hoc interface), implement it on the
+ * ethernet device, and then have QOM link properties on the DMA
+ * controller device so that you can pass the interface
+ * implementations to it.
+ */
+ ETRAX_FS_ETH(dev)->dma_out = dma_out;
+ ETRAX_FS_ETH(dev)->dma_in = dma_in;
+ qdev_init_nofail(dev);
+ sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
+
+ return dev;
+}
+
static const TypeInfo etraxfs_eth_info = {
.name = TYPE_ETRAX_FS_ETH,
.parent = TYPE_SYS_BUS_DEVICE,
diff --git a/include/hw/cris/etraxfs.h b/include/hw/cris/etraxfs.h
index aa146a2cd8..403e7f95e6 100644
--- a/include/hw/cris/etraxfs.h
+++ b/include/hw/cris/etraxfs.h
@@ -30,23 +30,9 @@
#include "hw/qdev-properties.h"
#include "hw/sysbus.h"
-/* Instantiate an ETRAXFS Ethernet MAC. */
-static inline DeviceState *
-etraxfs_eth_init(NICInfo *nd, hwaddr base, int phyaddr,
- void *dma_out, void *dma_in)
-{
- DeviceState *dev;
- qemu_check_nic_model(nd, "fseth");
-
- dev = qdev_create(NULL, "etraxfs-eth");
- qdev_set_nic_properties(dev, nd);
- qdev_prop_set_uint32(dev, "phyaddr", phyaddr);
- qdev_prop_set_ptr(dev, "dma_out", dma_out);
- qdev_prop_set_ptr(dev, "dma_in", dma_in);
- qdev_init_nofail(dev);
- sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
- return dev;
-}
+DeviceState *etraxfs_eth_init(NICInfo *nd, hwaddr base, int phyaddr,
+ struct etraxfs_dma_client *dma_out,
+ struct etraxfs_dma_client *dma_in);
static inline DeviceState *etraxfs_ser_create(hwaddr addr,
qemu_irq irq,
--
2.23.0.606.g08da6496b6
- [PATCH v3 20/33] vmmouse: replace PROP_PTR with PROP_LINK, (continued)
- [PATCH v3 20/33] vmmouse: replace PROP_PTR with PROP_LINK, Marc-André Lureau, 2019/10/23
- [PATCH v3 21/33] lance: replace PROP_PTR with PROP_LINK, Marc-André Lureau, 2019/10/23
- Re: [PATCH v3 21/33] lance: replace PROP_PTR with PROP_LINK, Philippe Mathieu-Daudé, 2019/10/23
- Re: [PATCH v3 21/33] lance: replace PROP_PTR with PROP_LINK, Marc-André Lureau, 2019/10/24
- Re: [PATCH v3 21/33] lance: replace PROP_PTR with PROP_LINK, Philippe Mathieu-Daudé, 2019/10/24
- Re: [PATCH v3 21/33] lance: replace PROP_PTR with PROP_LINK, Peter Maydell, 2019/10/24
- Re: [PATCH v3 21/33] lance: replace PROP_PTR with PROP_LINK, Eduardo Habkost, 2019/10/24
- Re: [PATCH v3 21/33] lance: replace PROP_PTR with PROP_LINK, Peter Maydell, 2019/10/25
- Re: [PATCH v3 21/33] lance: replace PROP_PTR with PROP_LINK, Marc-André Lureau, 2019/10/24
[PATCH v3 22/33] etraxfs: remove PROP_PTR usage,
Marc-André Lureau <=
[PATCH v3 23/33] dp8393x: replace PROP_PTR with PROP_LINK, Marc-André Lureau, 2019/10/23
[PATCH v3 24/33] leon3: use qemu_irq framework instead of callback as property, Marc-André Lureau, 2019/10/23
[PATCH v3 25/33] sparc: move PIL irq handling to cpu.c, Marc-André Lureau, 2019/10/23
[PATCH v3 26/33] RFC: mips/cps: fix setting saar property, Marc-André Lureau, 2019/10/23
[PATCH v3 27/33] cris: improve passing PIC interrupt vector to the CPU, Marc-André Lureau, 2019/10/23
[PATCH v3 29/33] omap-intc: remove PROP_PTR, Marc-André Lureau, 2019/10/23
[PATCH v3 28/33] smbus-eeprom: remove PROP_PTR, Marc-André Lureau, 2019/10/23