qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH-for-5.1 v3 11/24] hw/arm/msf2-soc: Store MemoryRegion in MSF2


From: Alistair Francis
Subject: Re: [PATCH-for-5.1 v3 11/24] hw/arm/msf2-soc: Store MemoryRegion in MSF2State
Date: Mon, 13 Apr 2020 14:59:41 -0700

On Sun, Apr 12, 2020 at 3:40 PM Philippe Mathieu-Daudé <address@hidden> wrote:
>
> Coccinelle reported:
>
>   $ spatch ... --timeout 60 --sp-file \
>     scripts/coccinelle/simplify-init-realize-error_propagate.cocci
>   HANDLING: ./hw/arm/msf2-soc.c
>   >>> possible moves from m2sxxx_soc_initfn() to m2sxxx_soc_realize() in 
> ./hw/arm/msf2-soc.c:86
>
> While reviewing we notice storing the MemoryRegion in the device
> state, we'll be able to later automatically simplify the error
> propagation calls.
>
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>

Reviewed-by: Alistair Francis <address@hidden>

Alistair

> ---
>  include/hw/arm/msf2-soc.h |  4 ++++
>  hw/arm/msf2-soc.c         | 18 +++++++-----------
>  2 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/include/hw/arm/msf2-soc.h b/include/hw/arm/msf2-soc.h
> index 3cfe5c76ee..e4c5110036 100644
> --- a/include/hw/arm/msf2-soc.h
> +++ b/include/hw/arm/msf2-soc.h
> @@ -50,6 +50,10 @@ typedef struct MSF2State {
>
>      ARMv7MState armv7m;
>
> +    MemoryRegion sram;
> +    MemoryRegion nvm;
> +    MemoryRegion nvm_alias;
> +
>      char *cpu_type;
>      char *part_name;
>      uint64_t envm_size;
> diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
> index 588d643b8d..e448b0ab74 100644
> --- a/hw/arm/msf2-soc.c
> +++ b/hw/arm/msf2-soc.c
> @@ -90,13 +90,9 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error 
> **errp)
>      SysBusDevice *busdev;
>      Error *err = NULL;
>      int i;
> -
>      MemoryRegion *system_memory = get_system_memory();
> -    MemoryRegion *nvm = g_new(MemoryRegion, 1);
> -    MemoryRegion *nvm_alias = g_new(MemoryRegion, 1);
> -    MemoryRegion *sram = g_new(MemoryRegion, 1);
>
> -    memory_region_init_rom(nvm, OBJECT(dev_soc), "MSF2.eNVM", s->envm_size,
> +    memory_region_init_rom(&s->nvm, OBJECT(dev_soc), "MSF2.eNVM", 
> s->envm_size,
>                             &error_fatal);
>      /*
>       * On power-on, the eNVM region 0x60000000 is automatically
> @@ -104,15 +100,15 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, 
> Error **errp)
>       * start address (0x0). We do not support remapping other eNVM,
>       * eSRAM and DDR regions by guest(via Sysreg) currently.
>       */
> -    memory_region_init_alias(nvm_alias, OBJECT(dev_soc), "MSF2.eNVM", nvm, 0,
> -                             s->envm_size);
> +    memory_region_init_alias(&s->nvm_alias, OBJECT(dev_soc), "MSF2.eNVM",
> +                             &s->nvm, 0, s->envm_size);
>
> -    memory_region_add_subregion(system_memory, ENVM_BASE_ADDRESS, nvm);
> -    memory_region_add_subregion(system_memory, 0, nvm_alias);
> +    memory_region_add_subregion(system_memory, ENVM_BASE_ADDRESS, &s->nvm);
> +    memory_region_add_subregion(system_memory, 0, &s->nvm_alias);
>
> -    memory_region_init_ram(sram, NULL, "MSF2.eSRAM", s->esram_size,
> +    memory_region_init_ram(&s->sram, NULL, "MSF2.eSRAM", s->esram_size,
>                             &error_fatal);
> -    memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, sram);
> +    memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, &s->sram);
>
>      armv7m = DEVICE(&s->armv7m);
>      qdev_prop_set_uint32(armv7m, "num-irq", 81);
> --
> 2.21.1
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]