diff mbox series

[RFC,PATCH-for-9.1,14/29] hw/i386/pc: Move pc_system_flash_create() to pc_pci_machine_initfn()

Message ID 20240328155439.58719-15-philmd@linaro.org
State New
Headers show
Series [RFC,PATCH-for-9.1,01/29] hw/i386/pc: Declare CPU QOM types using DEFINE_TYPES() macro | expand

Commit Message

Philippe Mathieu-Daudé March 28, 2024, 3:54 p.m. UTC
pc_system_flash_create() is only useful for PCI-based machines.
Move the call to the PCI-based init() handler.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/i386/pc.c       |  2 +-
 hw/i386/pc_sysfw.c | 10 ++++------
 2 files changed, 5 insertions(+), 7 deletions(-)

Comments

BALATON Zoltan March 28, 2024, 6:52 p.m. UTC | #1
On Thu, 28 Mar 2024, Philippe Mathieu-Daudé wrote:
> pc_system_flash_create() is only useful for PCI-based machines.
> Move the call to the PCI-based init() handler.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/i386/pc.c       |  2 +-
> hw/i386/pc_sysfw.c | 10 ++++------
> 2 files changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 5b96daa414..33724791fd 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -1679,7 +1679,6 @@ static void pc_machine_initfn(Object *obj)
>     pcms->fd_bootchk = true;
>     pcms->default_bus_bypass_iommu = false;
>
> -    pc_system_flash_create(pcms);
>     pcms->pcspk = isa_new(TYPE_PC_SPEAKER);
>     object_property_add_alias(OBJECT(pcms), "pcspk-audiodev",
>                               OBJECT(pcms->pcspk), "audiodev");
> @@ -1694,6 +1693,7 @@ static void pc_pci_machine_initfn(Object *obj)
>
>     ppms->acpi_build_enabled = true;
>
> +    pc_system_flash_create(PC_MACHINE(obj));
>     cxl_machine_init(obj, &ppms->cxl_devices_state);
>
>     ppms->machine_done.notify = pc_pci_machine_done;
> diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
> index 541dcaef71..167ff24fcb 100644
> --- a/hw/i386/pc_sysfw.c
> +++ b/hw/i386/pc_sysfw.c
> @@ -93,12 +93,10 @@ static PFlashCFI01 *pc_pflash_create(PCMachineState *pcms,
>
> void pc_system_flash_create(PCMachineState *pcms)
> {
> -    if (pc_machine_is_pci_enabled(pcms)) {
> -        pcms->flash[0] = pc_pflash_create(pcms, "system.flash0",
> -                                          "pflash0");
> -        pcms->flash[1] = pc_pflash_create(pcms, "system.flash1",
> -                                          "pflash1");
> -    }
> +    assert(pc_machine_is_pci_enabled(pcms));
> +
> +    pcms->flash[0] = pc_pflash_create(pcms, "system.flash0", "pflash0");
> +    pcms->flash[1] = pc_pflash_create(pcms, "system.flash1", "pflash1");
> }

This could just be inlined as it's called once, then no need for assert 
and a separate function.

Regards,
BALATON Zoltan

>
> void pc_system_flash_cleanup_unused(PCMachineState *pcms)
>
diff mbox series

Patch

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 5b96daa414..33724791fd 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1679,7 +1679,6 @@  static void pc_machine_initfn(Object *obj)
     pcms->fd_bootchk = true;
     pcms->default_bus_bypass_iommu = false;
 
-    pc_system_flash_create(pcms);
     pcms->pcspk = isa_new(TYPE_PC_SPEAKER);
     object_property_add_alias(OBJECT(pcms), "pcspk-audiodev",
                               OBJECT(pcms->pcspk), "audiodev");
@@ -1694,6 +1693,7 @@  static void pc_pci_machine_initfn(Object *obj)
 
     ppms->acpi_build_enabled = true;
 
+    pc_system_flash_create(PC_MACHINE(obj));
     cxl_machine_init(obj, &ppms->cxl_devices_state);
 
     ppms->machine_done.notify = pc_pci_machine_done;
diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
index 541dcaef71..167ff24fcb 100644
--- a/hw/i386/pc_sysfw.c
+++ b/hw/i386/pc_sysfw.c
@@ -93,12 +93,10 @@  static PFlashCFI01 *pc_pflash_create(PCMachineState *pcms,
 
 void pc_system_flash_create(PCMachineState *pcms)
 {
-    if (pc_machine_is_pci_enabled(pcms)) {
-        pcms->flash[0] = pc_pflash_create(pcms, "system.flash0",
-                                          "pflash0");
-        pcms->flash[1] = pc_pflash_create(pcms, "system.flash1",
-                                          "pflash1");
-    }
+    assert(pc_machine_is_pci_enabled(pcms));
+
+    pcms->flash[0] = pc_pflash_create(pcms, "system.flash0", "pflash0");
+    pcms->flash[1] = pc_pflash_create(pcms, "system.flash1", "pflash1");
 }
 
 void pc_system_flash_cleanup_unused(PCMachineState *pcms)