[PATCH v2 18/23] q800: move SWIM 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 18/23] q800: move SWIM device to Q800MachineState
Posted by Mark Cave-Ayland 2 years, 8 months ago
Also change the instantiation of the SWIM device to use object_initialize_child().

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

diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index befef5f822..f85ccf83af 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -407,10 +407,12 @@ static void q800_machine_init(MachineState *machine)
 
     /* SWIM floppy controller */
 
-    dev = qdev_new(TYPE_SWIM);
-    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
+    object_initialize_child(OBJECT(machine), "swim", &m->swim,
+                            TYPE_SWIM);
+    sysbus = SYS_BUS_DEVICE(&m->swim);
+    sysbus_realize(sysbus, &error_fatal);
     memory_region_add_subregion(&m->macio, SWIM_BASE - IO_BASE,
-                                sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0));
+                                sysbus_mmio_get_region(sysbus, 0));
 
     /* NuBus */
 
diff --git a/include/hw/m68k/q800.h b/include/hw/m68k/q800.h
index ba76aa37f2..ce8dbcd68f 100644
--- a/include/hw/m68k/q800.h
+++ b/include/hw/m68k/q800.h
@@ -29,6 +29,7 @@
 #include "hw/char/escc.h"
 #include "hw/or-irq.h"
 #include "hw/scsi/esp.h"
+#include "hw/block/swim.h"
 
 /*
  * The main Q800 machine
@@ -46,6 +47,7 @@ struct Q800MachineState {
     ESCCState escc;
     OrIRQState escc_orgate;
     SysBusESPState esp;
+    Swim swim;
     MemoryRegion macio;
     MemoryRegion macio_alias;
 };
-- 
2.30.2
Re: [PATCH v2 18/23] q800: move SWIM 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 SWIM device to use object_initialize_child().
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>   hw/m68k/q800.c         | 8 +++++---
>   include/hw/m68k/q800.h | 2 ++
>   2 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
> index befef5f822..f85ccf83af 100644
> --- a/hw/m68k/q800.c
> +++ b/hw/m68k/q800.c
> @@ -407,10 +407,12 @@ static void q800_machine_init(MachineState *machine)
>   
>       /* SWIM floppy controller */
>   
> -    dev = qdev_new(TYPE_SWIM);
> -    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
> +    object_initialize_child(OBJECT(machine), "swim", &m->swim,
> +                            TYPE_SWIM);
> +    sysbus = SYS_BUS_DEVICE(&m->swim);
> +    sysbus_realize(sysbus, &error_fatal);
>       memory_region_add_subregion(&m->macio, SWIM_BASE - IO_BASE,
> -                                sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0));
> +                                sysbus_mmio_get_region(sysbus, 0));
>   
>       /* NuBus */
>   
> diff --git a/include/hw/m68k/q800.h b/include/hw/m68k/q800.h
> index ba76aa37f2..ce8dbcd68f 100644
> --- a/include/hw/m68k/q800.h
> +++ b/include/hw/m68k/q800.h
> @@ -29,6 +29,7 @@
>   #include "hw/char/escc.h"
>   #include "hw/or-irq.h"
>   #include "hw/scsi/esp.h"
> +#include "hw/block/swim.h"
>   
>   /*
>    * The main Q800 machine
> @@ -46,6 +47,7 @@ struct Q800MachineState {
>       ESCCState escc;
>       OrIRQState escc_orgate;
>       SysBusESPState esp;
> +    Swim swim;
>       MemoryRegion macio;
>       MemoryRegion macio_alias;
>   };

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


Re: [PATCH v2 18/23] q800: move SWIM 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 SWIM device to use object_initialize_child().
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>   hw/m68k/q800.c         | 8 +++++---
>   include/hw/m68k/q800.h | 2 ++
>   2 files changed, 7 insertions(+), 3 deletions(-)

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