diff mbox series

[1/6] sparc32-dma: use object_initialize_child() for espdma and ledma child objects

Message ID 20200920082018.16135-2-mark.cave-ayland@ilande.co.uk
State Accepted
Commit 1f10fd53cbee9830db3e8d2f4ff0c7a507655fae
Headers show
Series QOM minor fixes | expand

Commit Message

Mark Cave-Ayland Sept. 20, 2020, 8:20 a.m. UTC
Store the child objects directly within the sparc32-dma object rather than using
link properties.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/dma/sparc32_dma.c           | 15 +++++++++------
 include/hw/sparc/sparc32_dma.h |  4 ++--
 2 files changed, 11 insertions(+), 8 deletions(-)

Comments

Philippe Mathieu-Daudé Sept. 20, 2020, 10:49 a.m. UTC | #1
On 9/20/20 10:20 AM, Mark Cave-Ayland wrote:
> Store the child objects directly within the sparc32-dma object rather than using

> link properties.

> 

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

> ---

>  hw/dma/sparc32_dma.c           | 15 +++++++++------

>  include/hw/sparc/sparc32_dma.h |  4 ++--


Consider using scripts/git.orderfile to avoid reviewer scrolling :)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


>  2 files changed, 11 insertions(+), 8 deletions(-)

> 

> diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c

> index d20a5bc065..b25a212f7a 100644

> --- a/hw/dma/sparc32_dma.c

> +++ b/hw/dma/sparc32_dma.c

> @@ -379,10 +379,9 @@ static void sparc32_dma_realize(DeviceState *dev, Error **errp)

>          return;

>      }

>  

> -    espdma = qdev_new(TYPE_SPARC32_ESPDMA_DEVICE);

> +    espdma = DEVICE(&s->espdma);

>      object_property_set_link(OBJECT(espdma), "iommu", iommu, &error_abort);

> -    object_property_add_child(OBJECT(s), "espdma", OBJECT(espdma));

> -    sysbus_realize_and_unref(SYS_BUS_DEVICE(espdma), &error_fatal);

> +    sysbus_realize(SYS_BUS_DEVICE(espdma), &error_fatal);

>  

>      esp = DEVICE(object_resolve_path_component(OBJECT(espdma), "esp"));

>      sbd = SYS_BUS_DEVICE(esp);

> @@ -394,10 +393,9 @@ static void sparc32_dma_realize(DeviceState *dev, Error **errp)

>      memory_region_add_subregion(&s->dmamem, 0x0,

>                                  sysbus_mmio_get_region(sbd, 0));

>  

> -    ledma = qdev_new(TYPE_SPARC32_LEDMA_DEVICE);

> +    ledma = DEVICE(&s->ledma);

>      object_property_set_link(OBJECT(ledma), "iommu", iommu, &error_abort);

> -    object_property_add_child(OBJECT(s), "ledma", OBJECT(ledma));

> -    sysbus_realize_and_unref(SYS_BUS_DEVICE(ledma), &error_fatal);

> +    sysbus_realize(SYS_BUS_DEVICE(ledma), &error_fatal);

>  

>      lance = DEVICE(object_resolve_path_component(OBJECT(ledma), "lance"));

>      sbd = SYS_BUS_DEVICE(lance);

> @@ -421,6 +419,11 @@ static void sparc32_dma_init(Object *obj)

>  

>      memory_region_init(&s->dmamem, OBJECT(s), "dma", DMA_SIZE + DMA_ETH_SIZE);

>      sysbus_init_mmio(sbd, &s->dmamem);

> +

> +    object_initialize_child(obj, "espdma", &s->espdma,

> +                            TYPE_SPARC32_ESPDMA_DEVICE);

> +    object_initialize_child(obj, "ledma", &s->ledma,

> +                            TYPE_SPARC32_LEDMA_DEVICE);

>  }

>  

>  static void sparc32_dma_class_init(ObjectClass *klass, void *data)

> diff --git a/include/hw/sparc/sparc32_dma.h b/include/hw/sparc/sparc32_dma.h

> index a402665a9c..a7b1dd8418 100644

> --- a/include/hw/sparc/sparc32_dma.h

> +++ b/include/hw/sparc/sparc32_dma.h

> @@ -56,8 +56,8 @@ struct SPARC32DMAState {

>  

>      MemoryRegion dmamem;

>      MemoryRegion ledma_alias;

> -    ESPDMADeviceState *espdma;

> -    LEDMADeviceState *ledma;

> +    ESPDMADeviceState espdma;

> +    LEDMADeviceState ledma;

>  };

>  

>  /* sparc32_dma.c */

>
diff mbox series

Patch

diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c
index d20a5bc065..b25a212f7a 100644
--- a/hw/dma/sparc32_dma.c
+++ b/hw/dma/sparc32_dma.c
@@ -379,10 +379,9 @@  static void sparc32_dma_realize(DeviceState *dev, Error **errp)
         return;
     }
 
-    espdma = qdev_new(TYPE_SPARC32_ESPDMA_DEVICE);
+    espdma = DEVICE(&s->espdma);
     object_property_set_link(OBJECT(espdma), "iommu", iommu, &error_abort);
-    object_property_add_child(OBJECT(s), "espdma", OBJECT(espdma));
-    sysbus_realize_and_unref(SYS_BUS_DEVICE(espdma), &error_fatal);
+    sysbus_realize(SYS_BUS_DEVICE(espdma), &error_fatal);
 
     esp = DEVICE(object_resolve_path_component(OBJECT(espdma), "esp"));
     sbd = SYS_BUS_DEVICE(esp);
@@ -394,10 +393,9 @@  static void sparc32_dma_realize(DeviceState *dev, Error **errp)
     memory_region_add_subregion(&s->dmamem, 0x0,
                                 sysbus_mmio_get_region(sbd, 0));
 
-    ledma = qdev_new(TYPE_SPARC32_LEDMA_DEVICE);
+    ledma = DEVICE(&s->ledma);
     object_property_set_link(OBJECT(ledma), "iommu", iommu, &error_abort);
-    object_property_add_child(OBJECT(s), "ledma", OBJECT(ledma));
-    sysbus_realize_and_unref(SYS_BUS_DEVICE(ledma), &error_fatal);
+    sysbus_realize(SYS_BUS_DEVICE(ledma), &error_fatal);
 
     lance = DEVICE(object_resolve_path_component(OBJECT(ledma), "lance"));
     sbd = SYS_BUS_DEVICE(lance);
@@ -421,6 +419,11 @@  static void sparc32_dma_init(Object *obj)
 
     memory_region_init(&s->dmamem, OBJECT(s), "dma", DMA_SIZE + DMA_ETH_SIZE);
     sysbus_init_mmio(sbd, &s->dmamem);
+
+    object_initialize_child(obj, "espdma", &s->espdma,
+                            TYPE_SPARC32_ESPDMA_DEVICE);
+    object_initialize_child(obj, "ledma", &s->ledma,
+                            TYPE_SPARC32_LEDMA_DEVICE);
 }
 
 static void sparc32_dma_class_init(ObjectClass *klass, void *data)
diff --git a/include/hw/sparc/sparc32_dma.h b/include/hw/sparc/sparc32_dma.h
index a402665a9c..a7b1dd8418 100644
--- a/include/hw/sparc/sparc32_dma.h
+++ b/include/hw/sparc/sparc32_dma.h
@@ -56,8 +56,8 @@  struct SPARC32DMAState {
 
     MemoryRegion dmamem;
     MemoryRegion ledma_alias;
-    ESPDMADeviceState *espdma;
-    LEDMADeviceState *ledma;
+    ESPDMADeviceState espdma;
+    LEDMADeviceState ledma;
 };
 
 /* sparc32_dma.c */