From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Fam Zheng" <fam@euphon.net>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Sagar Karandikar" <sagark@eecs.berkeley.edu>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Jeff Cody" <codyprime@gmail.com>,
"Jason Wang" <jasowang@redhat.com>,
"Alistair Francis" <Alistair.Francis@wdc.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Subbaraya Sundeep" <sundeep.lkml@gmail.com>,
qemu-block@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
"Max Reitz" <mreitz@redhat.com>, "Joel Stanley" <joel@jms.id.au>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Richard Henderson" <rth@twiddle.net>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Xie Changlong" <xiechanglong.d@gmail.com>,
"Alistair Francis" <alistair@alistair23.me>,
"Beniamino Galvani" <b.galvani@gmail.com>,
qemu-arm@nongnu.org, "Peter Chubb" <peter.chubb@nicta.com.au>,
"Cédric Le Goater" <clg@kaod.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"David Gibson" <david@gibson.dropbear.id.au>,
"Kevin Wolf" <kwolf@redhat.com>,
qemu-riscv@nongnu.org, "Andrew Jeffery" <andrew@aj.id.au>,
"Wen Congyang" <wencongyang2@huawei.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Jean-Christophe Dubois" <jcd@tribudubois.net>,
qemu-ppc@nongnu.org,
"Bastian Koppelmann" <kbastian@mail.uni-paderborn.de>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH-for-5.1 v3 11/24] hw/arm/msf2-soc: Store MemoryRegion in MSF2State
Date: Mon, 13 Apr 2020 00:36:06 +0200 [thread overview]
Message-ID: <20200412223619.11284-12-f4bug@amsat.org> (raw)
In-Reply-To: <20200412223619.11284-1-f4bug@amsat.org>
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é <f4bug@amsat.org>
---
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
next prev parent reply other threads:[~2020-04-12 22:40 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-12 22:35 [PATCH-for-5.1 v3 00/24] various: Fix error-propagation with Coccinelle scripts (part 1) Philippe Mathieu-Daudé
2020-04-12 22:35 ` [PATCH-for-5.1 v3 01/24] various: Remove suspicious '\' character outside of #define in C code Philippe Mathieu-Daudé
2020-04-13 15:56 ` Alistair Francis
2020-04-14 2:08 ` David Gibson
2020-04-29 6:03 ` Markus Armbruster
2020-04-12 22:35 ` [PATCH-for-5.1 v3 02/24] scripts/coccinelle: Script to simplify DeviceClass error propagation Philippe Mathieu-Daudé
2020-04-14 12:24 ` Markus Armbruster
2020-04-14 12:30 ` Philippe Mathieu-Daudé
2020-04-14 13:17 ` Markus Armbruster
2020-04-15 6:16 ` Philippe Mathieu-Daudé
2020-04-12 22:35 ` [PATCH-for-5.1 v3 03/24] hw/arm/allwinner-a10: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-13 21:02 ` Philippe Mathieu-Daudé
2020-04-12 22:35 ` [PATCH-for-5.1 v3 04/24] hw/arm/aspeed_ast2600: Simplify use of Error* Philippe Mathieu-Daudé
2020-04-12 22:36 ` [PATCH-for-5.1 v3 05/24] hw/arm/aspeed_ast2600: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-15 7:50 ` Cédric Le Goater
2020-04-12 22:36 ` [PATCH-for-5.1 v3 06/24] hw/arm/aspeed_soc: " Philippe Mathieu-Daudé
2020-04-12 22:36 ` [PATCH-for-5.1 v3 07/24] hw/arm/aspeed_soc: Simplify use of Error* Philippe Mathieu-Daudé
2020-04-12 22:36 ` [PATCH-for-5.1 v3 08/24] hw/arm/fsl-imx6: Simplify checks on 'smp_cpus' count Philippe Mathieu-Daudé
2020-04-12 22:36 ` [PATCH-for-5.1 v3 09/24] hw/arm/fsl-imx6: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-12 22:36 ` [PATCH-for-5.1 v3 10/24] hw/arm/fsl-imx31: " Philippe Mathieu-Daudé
2020-04-12 22:36 ` Philippe Mathieu-Daudé [this message]
2020-04-13 21:59 ` [PATCH-for-5.1 v3 11/24] hw/arm/msf2-soc: Store MemoryRegion in MSF2State Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 12/24] hw/arm/stm32f205_soc: Store MemoryRegion in STM32F205State Philippe Mathieu-Daudé
2020-04-13 22:00 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 13/24] hw/arm/stm32f205_soc: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-13 22:02 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 14/24] hw/arm/xlnx-zynqmp: Use single propagate_error() call Philippe Mathieu-Daudé
2020-04-13 22:05 ` Alistair Francis
2020-04-12 22:36 ` [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 22:36 ` [PATCH-for-5.1 v3 16/24] hw/arm/xlnx-zynqmp: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-13 22:06 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 17/24] hw/microblaze/xlnx-zynqmp-pmu: " Philippe Mathieu-Daudé
2020-04-13 22:19 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 18/24] hw/pci-host/pnv_phb3: " Philippe Mathieu-Daudé
2020-04-14 2:10 ` David Gibson
2020-04-15 7:51 ` Cédric Le Goater
2020-04-12 22:36 ` [PATCH-for-5.1 v3 19/24] hw/riscv/sifive_e: " Philippe Mathieu-Daudé
2020-04-13 22:20 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 20/24] hw/riscv/sifive_u: Use single type_init() Philippe Mathieu-Daudé
2020-04-13 22:10 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 21/24] hw/riscv/sifive_u: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-13 22:16 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 22/24] hw/riscv/sifive_u: Store MemoryRegion in SiFiveUSoCState Philippe Mathieu-Daudé
2020-04-13 22:14 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 23/24] hw/riscv/sifive_u: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-13 22:15 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 24/24] hw/riscv/sifive_u: Rename MachineClass::init() Philippe Mathieu-Daudé
2020-04-13 22:14 ` Alistair Francis
2020-04-13 0:39 ` [PATCH-for-5.1 v3 00/24] various: Fix error-propagation with Coccinelle scripts (part 1) no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200412223619.11284-12-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=Alistair.Francis@wdc.com \
--cc=alistair@alistair23.me \
--cc=andrew@aj.id.au \
--cc=armbru@redhat.com \
--cc=b.galvani@gmail.com \
--cc=clg@kaod.org \
--cc=codyprime@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=edgar.iglesias@gmail.com \
--cc=ehabkost@redhat.com \
--cc=fam@euphon.net \
--cc=jasowang@redhat.com \
--cc=jcd@tribudubois.net \
--cc=joel@jms.id.au \
--cc=kbastian@mail.uni-paderborn.de \
--cc=kwolf@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mreitz@redhat.com \
--cc=mst@redhat.com \
--cc=palmer@dabbelt.com \
--cc=pbonzini@redhat.com \
--cc=peter.chubb@nicta.com.au \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=rth@twiddle.net \
--cc=sagark@eecs.berkeley.edu \
--cc=sundeep.lkml@gmail.com \
--cc=wencongyang2@huawei.com \
--cc=xiechanglong.d@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).