diff mbox series

[5/7] hw/dma: Declare link using static DEFINE_PROP_LINK() macro

Message ID 20231017140150.44995-6-philmd@linaro.org
State Superseded
Headers show
Series hw: Few more QOM/QDev cleanups | expand

Commit Message

Philippe Mathieu-Daudé Oct. 17, 2023, 2:01 p.m. UTC
Declare link statically using DEFINE_PROP_LINK().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/dma/xilinx_axidma.c |  6 ++----
 hw/dma/xlnx-zdma.c     |  7 ++-----
 hw/dma/xlnx_csu_dma.c  | 13 ++++---------
 3 files changed, 8 insertions(+), 18 deletions(-)

Comments

Mark Cave-Ayland Oct. 17, 2023, 8:16 p.m. UTC | #1
On 17/10/2023 15:01, Philippe Mathieu-Daudé wrote:

> Declare link statically using DEFINE_PROP_LINK().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/dma/xilinx_axidma.c |  6 ++----
>   hw/dma/xlnx-zdma.c     |  7 ++-----
>   hw/dma/xlnx_csu_dma.c  | 13 ++++---------
>   3 files changed, 8 insertions(+), 18 deletions(-)
> 
> diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
> index 12c90267df..0ae056ed06 100644
> --- a/hw/dma/xilinx_axidma.c
> +++ b/hw/dma/xilinx_axidma.c
> @@ -577,10 +577,6 @@ static void xilinx_axidma_init(Object *obj)
>       object_initialize_child(OBJECT(s), "axistream-control-connected-target",
>                               &s->rx_control_dev,
>                               TYPE_XILINX_AXI_DMA_CONTROL_STREAM);
> -    object_property_add_link(obj, "dma", TYPE_MEMORY_REGION,
> -                             (Object **)&s->dma_mr,
> -                             qdev_prop_allow_set_link_before_realize,
> -                             OBJ_PROP_LINK_STRONG);
>   
>       sysbus_init_irq(sbd, &s->streams[0].irq);
>       sysbus_init_irq(sbd, &s->streams[1].irq);
> @@ -596,6 +592,8 @@ static Property axidma_properties[] = {
>                        tx_data_dev, TYPE_STREAM_SINK, StreamSink *),
>       DEFINE_PROP_LINK("axistream-control-connected", XilinxAXIDMA,
>                        tx_control_dev, TYPE_STREAM_SINK, StreamSink *),
> +    DEFINE_PROP_LINK("dma", XilinxAXIDMA, dma_mr,
> +                     TYPE_MEMORY_REGION, MemoryRegion *),
>       DEFINE_PROP_END_OF_LIST(),
>   };
>   
> diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c
> index 4eb7f66e9f..84c0083013 100644
> --- a/hw/dma/xlnx-zdma.c
> +++ b/hw/dma/xlnx-zdma.c
> @@ -795,11 +795,6 @@ static void zdma_init(Object *obj)
>                             TYPE_XLNX_ZDMA, ZDMA_R_MAX * 4);
>       sysbus_init_mmio(sbd, &s->iomem);
>       sysbus_init_irq(sbd, &s->irq_zdma_ch_imr);
> -
> -    object_property_add_link(obj, "dma", TYPE_MEMORY_REGION,
> -                             (Object **)&s->dma_mr,
> -                             qdev_prop_allow_set_link_before_realize,
> -                             OBJ_PROP_LINK_STRONG);
>   }
>   
>   static const VMStateDescription vmstate_zdma = {
> @@ -817,6 +812,8 @@ static const VMStateDescription vmstate_zdma = {
>   
>   static Property zdma_props[] = {
>       DEFINE_PROP_UINT32("bus-width", XlnxZDMA, cfg.bus_width, 64),
> +    DEFINE_PROP_LINK("dma", XlnxZDMA, dma_mr,
> +                     TYPE_MEMORY_REGION, MemoryRegion *),
>       DEFINE_PROP_END_OF_LIST(),
>   };
>   
> diff --git a/hw/dma/xlnx_csu_dma.c b/hw/dma/xlnx_csu_dma.c
> index 88002698a1..e89089821a 100644
> --- a/hw/dma/xlnx_csu_dma.c
> +++ b/hw/dma/xlnx_csu_dma.c
> @@ -702,6 +702,10 @@ static Property xlnx_csu_dma_properties[] = {
>        * which channel the device is connected to.
>        */
>       DEFINE_PROP_BOOL("is-dst", XlnxCSUDMA, is_dst, true),
> +    DEFINE_PROP_LINK("stream-connected-dma", XlnxCSUDMA, tx_dev,
> +                     TYPE_STREAM_SINK, StreamSink *),
> +    DEFINE_PROP_LINK("dma", XlnxCSUDMA, dma_mr,
> +                     TYPE_MEMORY_REGION, MemoryRegion *),
>       DEFINE_PROP_END_OF_LIST(),
>   };
>   
> @@ -728,15 +732,6 @@ static void xlnx_csu_dma_init(Object *obj)
>   
>       memory_region_init(&s->iomem, obj, TYPE_XLNX_CSU_DMA,
>                          XLNX_CSU_DMA_R_MAX * 4);
> -
> -    object_property_add_link(obj, "stream-connected-dma", TYPE_STREAM_SINK,
> -                             (Object **)&s->tx_dev,
> -                             qdev_prop_allow_set_link_before_realize,
> -                             OBJ_PROP_LINK_STRONG);
> -    object_property_add_link(obj, "dma", TYPE_MEMORY_REGION,
> -                             (Object **)&s->dma_mr,
> -                             qdev_prop_allow_set_link_before_realize,
> -                             OBJ_PROP_LINK_STRONG);
>   }
>   
>   static const TypeInfo xlnx_csu_dma_info = {

Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


ATB,

Mark.
diff mbox series

Patch

diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
index 12c90267df..0ae056ed06 100644
--- a/hw/dma/xilinx_axidma.c
+++ b/hw/dma/xilinx_axidma.c
@@ -577,10 +577,6 @@  static void xilinx_axidma_init(Object *obj)
     object_initialize_child(OBJECT(s), "axistream-control-connected-target",
                             &s->rx_control_dev,
                             TYPE_XILINX_AXI_DMA_CONTROL_STREAM);
-    object_property_add_link(obj, "dma", TYPE_MEMORY_REGION,
-                             (Object **)&s->dma_mr,
-                             qdev_prop_allow_set_link_before_realize,
-                             OBJ_PROP_LINK_STRONG);
 
     sysbus_init_irq(sbd, &s->streams[0].irq);
     sysbus_init_irq(sbd, &s->streams[1].irq);
@@ -596,6 +592,8 @@  static Property axidma_properties[] = {
                      tx_data_dev, TYPE_STREAM_SINK, StreamSink *),
     DEFINE_PROP_LINK("axistream-control-connected", XilinxAXIDMA,
                      tx_control_dev, TYPE_STREAM_SINK, StreamSink *),
+    DEFINE_PROP_LINK("dma", XilinxAXIDMA, dma_mr,
+                     TYPE_MEMORY_REGION, MemoryRegion *),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c
index 4eb7f66e9f..84c0083013 100644
--- a/hw/dma/xlnx-zdma.c
+++ b/hw/dma/xlnx-zdma.c
@@ -795,11 +795,6 @@  static void zdma_init(Object *obj)
                           TYPE_XLNX_ZDMA, ZDMA_R_MAX * 4);
     sysbus_init_mmio(sbd, &s->iomem);
     sysbus_init_irq(sbd, &s->irq_zdma_ch_imr);
-
-    object_property_add_link(obj, "dma", TYPE_MEMORY_REGION,
-                             (Object **)&s->dma_mr,
-                             qdev_prop_allow_set_link_before_realize,
-                             OBJ_PROP_LINK_STRONG);
 }
 
 static const VMStateDescription vmstate_zdma = {
@@ -817,6 +812,8 @@  static const VMStateDescription vmstate_zdma = {
 
 static Property zdma_props[] = {
     DEFINE_PROP_UINT32("bus-width", XlnxZDMA, cfg.bus_width, 64),
+    DEFINE_PROP_LINK("dma", XlnxZDMA, dma_mr,
+                     TYPE_MEMORY_REGION, MemoryRegion *),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/dma/xlnx_csu_dma.c b/hw/dma/xlnx_csu_dma.c
index 88002698a1..e89089821a 100644
--- a/hw/dma/xlnx_csu_dma.c
+++ b/hw/dma/xlnx_csu_dma.c
@@ -702,6 +702,10 @@  static Property xlnx_csu_dma_properties[] = {
      * which channel the device is connected to.
      */
     DEFINE_PROP_BOOL("is-dst", XlnxCSUDMA, is_dst, true),
+    DEFINE_PROP_LINK("stream-connected-dma", XlnxCSUDMA, tx_dev,
+                     TYPE_STREAM_SINK, StreamSink *),
+    DEFINE_PROP_LINK("dma", XlnxCSUDMA, dma_mr,
+                     TYPE_MEMORY_REGION, MemoryRegion *),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -728,15 +732,6 @@  static void xlnx_csu_dma_init(Object *obj)
 
     memory_region_init(&s->iomem, obj, TYPE_XLNX_CSU_DMA,
                        XLNX_CSU_DMA_R_MAX * 4);
-
-    object_property_add_link(obj, "stream-connected-dma", TYPE_STREAM_SINK,
-                             (Object **)&s->tx_dev,
-                             qdev_prop_allow_set_link_before_realize,
-                             OBJ_PROP_LINK_STRONG);
-    object_property_add_link(obj, "dma", TYPE_MEMORY_REGION,
-                             (Object **)&s->dma_mr,
-                             qdev_prop_allow_set_link_before_realize,
-                             OBJ_PROP_LINK_STRONG);
 }
 
 static const TypeInfo xlnx_csu_dma_info = {