[PATCH v2 16/23] q800: move escc_orgate device to Q800MachineState

Mark Cave-Ayland posted 23 patches 2 years, 8 months ago
Maintainers: Laurent Vivier <laurent@vivier.eu>, Jason Wang <jasowang@redhat.com>
There is a newer version of this series
[PATCH v2 16/23] q800: move escc_orgate device to Q800MachineState
Posted by Mark Cave-Ayland 2 years, 8 months ago
Also change the instantiation of the escc_orgate device to use object_initialize_child().

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/m68k/q800.c         | 16 +++++++++-------
 include/hw/m68k/q800.h |  2 ++
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index ac92daf190..6f54677e5f 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -212,7 +212,6 @@ static void q800_machine_init(MachineState *machine)
     hwaddr parameters_base;
     CPUState *cs;
     DeviceState *dev;
-    DeviceState *escc_orgate;
     SysBusESPState *sysbus_esp;
     ESPState *esp;
     SysBusDevice *sysbus;
@@ -362,12 +361,15 @@ static void q800_machine_init(MachineState *machine)
     sysbus_realize(sysbus, &error_fatal);
 
     /* Logically OR both its IRQs together */
-    escc_orgate = DEVICE(object_new(TYPE_OR_IRQ));
-    object_property_set_int(OBJECT(escc_orgate), "num-lines", 2, &error_fatal);
-    qdev_realize_and_unref(escc_orgate, NULL, &error_fatal);
-    sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in(escc_orgate, 0));
-    sysbus_connect_irq(sysbus, 1, qdev_get_gpio_in(escc_orgate, 1));
-    qdev_connect_gpio_out(DEVICE(escc_orgate), 0,
+    object_initialize_child(OBJECT(machine), "escc_orgate", &m->escc_orgate,
+                            TYPE_OR_IRQ);
+    object_property_set_int(OBJECT(&m->escc_orgate), "num-lines", 2,
+                            &error_fatal);
+    dev = DEVICE(&m->escc_orgate);
+    qdev_realize(dev, NULL, &error_fatal);
+    sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in(dev, 0));
+    sysbus_connect_irq(sysbus, 1, qdev_get_gpio_in(dev, 1));
+    qdev_connect_gpio_out(dev, 0,
                           qdev_get_gpio_in(DEVICE(&m->glue),
                                            GLUE_IRQ_IN_ESCC));
     memory_region_add_subregion(&m->macio, SCC_BASE - IO_BASE,
diff --git a/include/hw/m68k/q800.h b/include/hw/m68k/q800.h
index d03603fe02..f9af314ee1 100644
--- a/include/hw/m68k/q800.h
+++ b/include/hw/m68k/q800.h
@@ -27,6 +27,7 @@
 #include "hw/misc/mac_via.h"
 #include "hw/net/dp8393x.h"
 #include "hw/char/escc.h"
+#include "hw/or-irq.h"
 
 /*
  * The main Q800 machine
@@ -42,6 +43,7 @@ struct Q800MachineState {
     MOS6522Q800VIA2State via2;
     dp8393xState dp8393x;
     ESCCState escc;
+    OrIRQState escc_orgate;
     MemoryRegion macio;
     MemoryRegion macio_alias;
 };
-- 
2.30.2
Re: [PATCH v2 16/23] q800: move escc_orgate device to Q800MachineState
Posted by Laurent Vivier 2 years, 8 months ago
Le 31/05/2023 à 14:53, Mark Cave-Ayland a écrit :
> Also change the instantiation of the escc_orgate device to use object_initialize_child().
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>   hw/m68k/q800.c         | 16 +++++++++-------
>   include/hw/m68k/q800.h |  2 ++
>   2 files changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
> index ac92daf190..6f54677e5f 100644
> --- a/hw/m68k/q800.c
> +++ b/hw/m68k/q800.c
> @@ -212,7 +212,6 @@ static void q800_machine_init(MachineState *machine)
>       hwaddr parameters_base;
>       CPUState *cs;
>       DeviceState *dev;
> -    DeviceState *escc_orgate;
>       SysBusESPState *sysbus_esp;
>       ESPState *esp;
>       SysBusDevice *sysbus;
> @@ -362,12 +361,15 @@ static void q800_machine_init(MachineState *machine)
>       sysbus_realize(sysbus, &error_fatal);
>   
>       /* Logically OR both its IRQs together */
> -    escc_orgate = DEVICE(object_new(TYPE_OR_IRQ));
> -    object_property_set_int(OBJECT(escc_orgate), "num-lines", 2, &error_fatal);
> -    qdev_realize_and_unref(escc_orgate, NULL, &error_fatal);
> -    sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in(escc_orgate, 0));
> -    sysbus_connect_irq(sysbus, 1, qdev_get_gpio_in(escc_orgate, 1));
> -    qdev_connect_gpio_out(DEVICE(escc_orgate), 0,
> +    object_initialize_child(OBJECT(machine), "escc_orgate", &m->escc_orgate,
> +                            TYPE_OR_IRQ);
> +    object_property_set_int(OBJECT(&m->escc_orgate), "num-lines", 2,
> +                            &error_fatal);
> +    dev = DEVICE(&m->escc_orgate);
> +    qdev_realize(dev, NULL, &error_fatal);
> +    sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in(dev, 0));
> +    sysbus_connect_irq(sysbus, 1, qdev_get_gpio_in(dev, 1));
> +    qdev_connect_gpio_out(dev, 0,
>                             qdev_get_gpio_in(DEVICE(&m->glue),
>                                              GLUE_IRQ_IN_ESCC));
>       memory_region_add_subregion(&m->macio, SCC_BASE - IO_BASE,
> diff --git a/include/hw/m68k/q800.h b/include/hw/m68k/q800.h
> index d03603fe02..f9af314ee1 100644
> --- a/include/hw/m68k/q800.h
> +++ b/include/hw/m68k/q800.h
> @@ -27,6 +27,7 @@
>   #include "hw/misc/mac_via.h"
>   #include "hw/net/dp8393x.h"
>   #include "hw/char/escc.h"
> +#include "hw/or-irq.h"
>   
>   /*
>    * The main Q800 machine
> @@ -42,6 +43,7 @@ struct Q800MachineState {
>       MOS6522Q800VIA2State via2;
>       dp8393xState dp8393x;
>       ESCCState escc;
> +    OrIRQState escc_orgate;
>       MemoryRegion macio;
>       MemoryRegion macio_alias;
>   };

Reviewed-by: Laurent Vivier <laurent@vivier.eu>


Re: [PATCH v2 16/23] q800: move escc_orgate device to Q800MachineState
Posted by Philippe Mathieu-Daudé 2 years, 8 months ago
On 31/5/23 14:53, Mark Cave-Ayland wrote:
> Also change the instantiation of the escc_orgate device to use object_initialize_child().
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>   hw/m68k/q800.c         | 16 +++++++++-------
>   include/hw/m68k/q800.h |  2 ++
>   2 files changed, 11 insertions(+), 7 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>