[PATCH] hw/unicore32/puv3: Simplify puv3_soc_init()

Philippe Mathieu-Daudé posted 1 patch 4 years, 1 month ago
Test docker-quick@centos7 passed
Test FreeBSD passed
Test docker-mingw@fedora passed
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200221162325.28194-1-philmd@redhat.com
Maintainers: Guan Xuetao <gxt@mprc.pku.edu.cn>
hw/unicore32/puv3.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
[PATCH] hw/unicore32/puv3: Simplify puv3_soc_init()
Posted by Philippe Mathieu-Daudé 4 years, 1 month ago
Since commit d8ed887bdc, the puv3_intc_cpu_handler handler takes
a pointer to UniCore32CPU in its opaque argument.  Directly pass
the cpu pointer.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/unicore32/puv3.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/unicore32/puv3.c b/hw/unicore32/puv3.c
index 7e933de228..eec7f561eb 100644
--- a/hw/unicore32/puv3.c
+++ b/hw/unicore32/puv3.c
@@ -48,7 +48,7 @@ static void puv3_intc_cpu_handler(void *opaque, int irq, int level)
     }
 }
 
-static void puv3_soc_init(CPUUniCore32State *env)
+static void puv3_soc_init(UniCore32CPU *cpu)
 {
     qemu_irq cpu_intc, irqs[PUV3_IRQS_NR];
     DeviceState *dev;
@@ -56,8 +56,7 @@ static void puv3_soc_init(CPUUniCore32State *env)
     int i;
 
     /* Initialize interrupt controller */
-    cpu_intc = qemu_allocate_irq(puv3_intc_cpu_handler,
-                                 env_archcpu(env), 0);
+    cpu_intc = qemu_allocate_irq(puv3_intc_cpu_handler, cpu, 0);
     dev = sysbus_create_simple("puv3_intc", PUV3_INTC_BASE, cpu_intc);
     for (i = 0; i < PUV3_IRQS_NR; i++) {
         irqs[i] = qdev_get_gpio_in(dev, i);
@@ -131,7 +130,7 @@ static void puv3_init(MachineState *machine)
     cpu = UNICORE32_CPU(cpu_create(machine->cpu_type));
     env = &cpu->env;
 
-    puv3_soc_init(env);
+    puv3_soc_init(cpu);
     puv3_board_init(env, ram_size);
     puv3_load_kernel(kernel_filename);
 }
-- 
2.21.1


Re: [PATCH] hw/unicore32/puv3: Simplify puv3_soc_init()
Posted by Laurent Vivier 4 years, 1 month ago
Le 21/02/2020 à 17:23, Philippe Mathieu-Daudé a écrit :
> Since commit d8ed887bdc, the puv3_intc_cpu_handler handler takes
> a pointer to UniCore32CPU in its opaque argument.  Directly pass
> the cpu pointer.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  hw/unicore32/puv3.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/unicore32/puv3.c b/hw/unicore32/puv3.c
> index 7e933de228..eec7f561eb 100644
> --- a/hw/unicore32/puv3.c
> +++ b/hw/unicore32/puv3.c
> @@ -48,7 +48,7 @@ static void puv3_intc_cpu_handler(void *opaque, int irq, int level)
>      }
>  }
>  
> -static void puv3_soc_init(CPUUniCore32State *env)
> +static void puv3_soc_init(UniCore32CPU *cpu)
>  {
>      qemu_irq cpu_intc, irqs[PUV3_IRQS_NR];
>      DeviceState *dev;
> @@ -56,8 +56,7 @@ static void puv3_soc_init(CPUUniCore32State *env)
>      int i;
>  
>      /* Initialize interrupt controller */
> -    cpu_intc = qemu_allocate_irq(puv3_intc_cpu_handler,
> -                                 env_archcpu(env), 0);
> +    cpu_intc = qemu_allocate_irq(puv3_intc_cpu_handler, cpu, 0);
>      dev = sysbus_create_simple("puv3_intc", PUV3_INTC_BASE, cpu_intc);
>      for (i = 0; i < PUV3_IRQS_NR; i++) {
>          irqs[i] = qdev_get_gpio_in(dev, i);
> @@ -131,7 +130,7 @@ static void puv3_init(MachineState *machine)
>      cpu = UNICORE32_CPU(cpu_create(machine->cpu_type));
>      env = &cpu->env;
>  
> -    puv3_soc_init(env);
> +    puv3_soc_init(cpu);
>      puv3_board_init(env, ram_size);
>      puv3_load_kernel(kernel_filename);
>  }
> 

I think you can remove totally env as puv3_board_init() doesn't use it.

Thanks,
Laurent