On Sun, Apr 12, 2020 at 3:42 PM Philippe Mathieu-Daudé <f4...@amsat.org> wrote: > > Coccinelle reported: > > $ spatch ... --timeout 60 --sp-file \ > scripts/coccinelle/simplify-init-realize-error_propagate.cocci > HANDLING: ./hw/arm/stm32f205_soc.c > >>> possible moves from stm32f205_soc_initfn() to stm32f205_soc_realize() > in ./hw/arm/stm32f205_soc.c:83 > > Move the calls using &error_fatal which don't depend on input > updated before realize() to init(). > > Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org>
Reviewed-by: Alistair Francis <alistair.fran...@wdc.com> Alistair > --- > v3: Typo 'depend of' -> 'depend on' (eblake) > --- > hw/arm/stm32f205_soc.c | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) > > diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c > index 42f4e44134..76b0b0e9be 100644 > --- a/hw/arm/stm32f205_soc.c > +++ b/hw/arm/stm32f205_soc.c > @@ -49,6 +49,7 @@ static const int spi_irq[STM_NUM_SPIS] = {35, 36, 51}; > static void stm32f205_soc_initfn(Object *obj) > { > STM32F205State *s = STM32F205_SOC(obj); > + MemoryRegion *system_memory = get_system_memory(); > int i; > > sysbus_init_child_obj(obj, "armv7m", &s->armv7m, sizeof(s->armv7m), > @@ -78,6 +79,14 @@ static void stm32f205_soc_initfn(Object *obj) > sysbus_init_child_obj(obj, "spi[*]", &s->spi[i], sizeof(s->spi[i]), > TYPE_STM32F2XX_SPI); > } > + > + memory_region_init_ram(&s->sram, NULL, "STM32F205.sram", SRAM_SIZE, > + &error_fatal); > + memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, &s->sram); > + > + memory_region_init_rom(&s->flash, obj, "STM32F205.flash", > + FLASH_SIZE, &error_fatal); > + memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, > &s->flash); > } > > static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp) > @@ -87,19 +96,10 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, > Error **errp) > SysBusDevice *busdev; > Error *err = NULL; > int i; > - MemoryRegion *system_memory = get_system_memory(); > > - memory_region_init_rom(&s->flash, OBJECT(dev_soc), "STM32F205.flash", > - FLASH_SIZE, &error_fatal); > memory_region_init_alias(&s->flash_alias, OBJECT(dev_soc), > "STM32F205.flash.alias", &s->flash, 0, > FLASH_SIZE); > - > - memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, > &s->flash); > - memory_region_add_subregion(system_memory, 0, &s->flash_alias); > - > - memory_region_init_ram(&s->sram, NULL, "STM32F205.sram", SRAM_SIZE, > - &error_fatal); > - memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, &s->sram); > + memory_region_add_subregion(get_system_memory(), 0, &s->flash_alias); > > armv7m = DEVICE(&s->armv7m); > qdev_prop_set_uint32(armv7m, "num-irq", 96); > -- > 2.21.1 > >