All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [PATCH v5 24/37] etraxfs: remove PROP_PTR usage
Date: Fri, 20 Dec 2019 17:45:48 +0400	[thread overview]
Message-ID: <20191220134601.571905-25-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <20191220134601.571905-1-marcandre.lureau@redhat.com>

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 <marcandre.lureau@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
 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.24.0.308.g228f53135a



  parent reply	other threads:[~2019-12-20 14:01 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-20 13:45 [PATCH v5 00/37] Clean-ups: qom-ify serial and remove QDEV_PROP_PTR Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 01/37] hw/display/sm501: Always map the UART0 Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 02/37] sysbus: remove unused sysbus_try_create* Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 03/37] sysbus: remove outdated comment Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 04/37] chardev: generate an internal id when none given Marc-André Lureau
2019-12-23  7:46   ` xiaoqiang zhao
2019-12-20 13:45 ` [PATCH v5 05/37] serial-pci-multi: factor out multi_serial_get_port_count() Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 06/37] serial: initial qom-ification Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 07/37] serial: register vmsd with DeviceClass Marc-André Lureau
2019-12-23  7:38   ` xiaoqiang zhao
2019-12-23  7:50   ` xiaoqiang zhao
2019-12-20 13:45 ` [PATCH v5 08/37] serial: add "chardev" property Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 09/37] serial: add "baudbase" property Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 10/37] serial: realize the serial device Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 11/37] serial: replace serial_exit_core() with unrealize Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 12/37] serial: start making SerialMM a sysbus device Marc-André Lureau
2020-01-07 12:52   ` Marc-André Lureau
2020-01-07 12:55   ` Peter Maydell
2020-01-07 13:25     ` Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 13/37] serial-mm: add "regshift" property Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 14/37] serial-mm: add endianness property Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 15/37] serial-mm: use sysbus facilities Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 16/37] serial: make SerialIO a sysbus device Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 17/37] mips: inline serial_init() Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 18/37] mips: baudbase is 115200 by default Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 19/37] mips: use sysbus_add_io() Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 20/37] mips: use sysbus_mmio_get_region() instead of internal fields Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 21/37] sm501: make SerialMM a child, export chardev property Marc-André Lureau
2020-01-07 12:52   ` Marc-André Lureau
2020-01-07 12:56   ` Peter Maydell
2019-12-20 13:45 ` [PATCH v5 22/37] vmmouse: replace PROP_PTR with PROP_LINK Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 23/37] lance: " Marc-André Lureau
2019-12-20 13:45 ` Marc-André Lureau [this message]
2019-12-20 13:45 ` [PATCH v5 25/37] dp8393x: " Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 26/37] leon3: use qemu_irq framework instead of callback as property Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 27/37] leon3: use qdev gpio facilities for the PIL Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 28/37] qdev: use g_strcmp0() instead of open-coding it Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 29/37] mips/cps: fix setting saar property Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 30/37] cris: improve passing PIC interrupt vector to the CPU Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 31/37] smbus-eeprom: remove PROP_PTR Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 32/37] omap-intc: " Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 33/37] omap-i2c: " Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 34/37] omap-gpio: " Marc-André Lureau
2019-12-20 13:45 ` [PATCH v5 35/37] qdev: remove PROP_MEMORY_REGION Marc-André Lureau
2019-12-20 13:46 ` [PATCH v5 36/37] qdev: remove QDEV_PROP_PTR Marc-André Lureau
2019-12-20 13:46 ` [PATCH v5 37/37] qdev/qom: remove some TODO limitations now that PROP_PTR is gone Marc-André Lureau
2019-12-20 16:39   ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191220134601.571905-25-marcandre.lureau@redhat.com \
    --to=marcandre.lureau@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.