diff mbox series

[15/19] cpus: Replace first_cpu by qemu_get_cpu(0, TYPE_RISCV_CPU)

Message ID 20231020163643.86105-16-philmd@linaro.org
State New
Headers show
Series cpus: Step toward removing global 'first_cpu' | expand

Commit Message

Philippe Mathieu-Daudé Oct. 20, 2023, 4:36 p.m. UTC
Mechanical change using the following coccinelle script:

  @@ @@
  -   first_cpu
  +   qemu_get_cpu(0, TYPE_RISCV_CPU)

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/riscv/boot.c          | 2 +-
 target/riscv/arch_dump.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
index 1d004660d4..5e979f7b6a 100644
--- a/hw/riscv/boot.c
+++ b/hw/riscv/boot.c
@@ -437,7 +437,7 @@  void riscv_setup_direct_kernel(hwaddr kernel_addr, hwaddr fdt_addr)
 {
     CPUState *cs;
 
-    for (cs = first_cpu; cs; cs = CPU_NEXT(cs)) {
+    for (cs = qemu_get_cpu(0, TYPE_RISCV_CPU); cs; cs = CPU_NEXT(cs)) {
         RISCVCPU *riscv_cpu = RISCV_CPU(cs);
         riscv_cpu->env.kernel_addr = kernel_addr;
         riscv_cpu->env.fdt_addr = fdt_addr;
diff --git a/target/riscv/arch_dump.c b/target/riscv/arch_dump.c
index 434c8a3dbb..4813d1ac1f 100644
--- a/target/riscv/arch_dump.c
+++ b/target/riscv/arch_dump.c
@@ -167,10 +167,10 @@  int cpu_get_dump_info(ArchDumpInfo *info,
     RISCVCPU *cpu;
     CPURISCVState *env;
 
-    if (first_cpu == NULL) {
+    if (qemu_get_cpu(0, TYPE_RISCV_CPU) == NULL) {
         return -1;
     }
-    cpu = RISCV_CPU(first_cpu);
+    cpu = RISCV_CPU(qemu_get_cpu(0, TYPE_RISCV_CPU));
     env = &cpu->env;
 
     info->d_machine = EM_RISCV;