[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH-for-5.1 v3 13/24] hw/arm/stm32f205_soc: Move some code from reali
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH-for-5.1 v3 13/24] hw/arm/stm32f205_soc: Move some code from realize() to init() |
Date: |
Mon, 13 Apr 2020 00:36:08 +0200 |
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é <address@hidden>
---
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
- Re: [PATCH-for-5.1 v3 05/24] hw/arm/aspeed_ast2600: Move some code from realize() to init(), (continued)
- [PATCH-for-5.1 v3 06/24] hw/arm/aspeed_soc: Move some code from realize() to init(), Philippe Mathieu-Daudé, 2020/04/12
- [PATCH-for-5.1 v3 07/24] hw/arm/aspeed_soc: Simplify use of Error*, Philippe Mathieu-Daudé, 2020/04/12
- [PATCH-for-5.1 v3 08/24] hw/arm/fsl-imx6: Simplify checks on 'smp_cpus' count, Philippe Mathieu-Daudé, 2020/04/12
- [PATCH-for-5.1 v3 09/24] hw/arm/fsl-imx6: Move some code from realize() to init(), Philippe Mathieu-Daudé, 2020/04/12
- [PATCH-for-5.1 v3 10/24] hw/arm/fsl-imx31: Move some code from realize() to init(), Philippe Mathieu-Daudé, 2020/04/12
- [PATCH-for-5.1 v3 11/24] hw/arm/msf2-soc: Store MemoryRegion in MSF2State, Philippe Mathieu-Daudé, 2020/04/12
- [PATCH-for-5.1 v3 12/24] hw/arm/stm32f205_soc: Store MemoryRegion in STM32F205State, Philippe Mathieu-Daudé, 2020/04/12
- [PATCH-for-5.1 v3 13/24] hw/arm/stm32f205_soc: Move some code from realize() to init(),
Philippe Mathieu-Daudé <=
- [PATCH-for-5.1 v3 14/24] hw/arm/xlnx-zynqmp: Use single propagate_error() call, Philippe Mathieu-Daudé, 2020/04/12
- [PATCH-for-5.1 v3 15/24] hw/arm/xlnx-zynqmp: Split xlnx_zynqmp_create_rpu() as init + realize, Philippe Mathieu-Daudé, 2020/04/12
- [PATCH-for-5.1 v3 16/24] hw/arm/xlnx-zynqmp: Move some code from realize() to init(), Philippe Mathieu-Daudé, 2020/04/12
- [PATCH-for-5.1 v3 17/24] hw/microblaze/xlnx-zynqmp-pmu: Move some code from realize() to init(), Philippe Mathieu-Daudé, 2020/04/12
- [PATCH-for-5.1 v3 18/24] hw/pci-host/pnv_phb3: Move some code from realize() to init(), Philippe Mathieu-Daudé, 2020/04/12