From: "Cédric Le Goater" <clg@kaod.org>
To: Peter Maydell <peter.maydell@linaro.org>,
Peter Crosthwaite <crosthwaite.peter@gmail.com>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org,
"Andrew Jeffery" <andrew@aj.id.au>,
"Cédric Le Goater" <clg@kaod.org>
Subject: [Qemu-devel] [PATCH 2/5] ast2400: replace aspeed_smc_is_implemented()
Date: Fri, 8 Jul 2016 18:06:53 +0200 [thread overview]
Message-ID: <1467994016-11678-3-git-send-email-clg@kaod.org> (raw)
In-Reply-To: <1467994016-11678-1-git-send-email-clg@kaod.org>
aspeed_smc_is_implemented() filters invalid registers in a peculiar
way. Let's remove it and open code the if conditions. It serves the
same purpose, the aesthetic is better, and new registers can easily be
added.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/ssi/aspeed_smc.c | 35 +++++++++++++++--------------------
1 file changed, 15 insertions(+), 20 deletions(-)
diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
index a371e302d448..854474b642ea 100644
--- a/hw/ssi/aspeed_smc.c
+++ b/hw/ssi/aspeed_smc.c
@@ -281,12 +281,6 @@ static void aspeed_smc_reset(DeviceState *d)
aspeed_smc_update_cs(s);
}
-static bool aspeed_smc_is_implemented(AspeedSMCState *s, hwaddr addr)
-{
- return (addr == s->r_conf || addr == s->r_timings || addr == s->r_ce_ctrl ||
- (addr >= s->r_ctrl0 && addr < s->r_ctrl0 + s->num_cs));
-}
-
static uint64_t aspeed_smc_read(void *opaque, hwaddr addr, unsigned int size)
{
AspeedSMCState *s = ASPEED_SMC(opaque);
@@ -300,13 +294,16 @@ static uint64_t aspeed_smc_read(void *opaque, hwaddr addr, unsigned int size)
return 0;
}
- if (!aspeed_smc_is_implemented(s, addr)) {
+ if (addr == s->r_conf ||
+ addr == s->r_timings ||
+ addr == s->r_ce_ctrl ||
+ (addr >= s->r_ctrl0 && addr < s->r_ctrl0 + s->num_cs)) {
+ return s->regs[addr];
+ } else {
qemu_log_mask(LOG_UNIMP, "%s: not implemented: 0x%" HWADDR_PRIx "\n",
- __func__, addr);
+ __func__, addr);
return 0;
}
-
- return s->regs[addr];
}
static void aspeed_smc_write(void *opaque, hwaddr addr, uint64_t data,
@@ -324,20 +321,18 @@ static void aspeed_smc_write(void *opaque, hwaddr addr, uint64_t data,
return;
}
- if (!aspeed_smc_is_implemented(s, addr)) {
+ if (addr == s->r_conf ||
+ addr == s->r_timings ||
+ addr == s->r_ce_ctrl) {
+ s->regs[addr] = value;
+ } else if (addr >= s->r_ctrl0 && addr < s->r_ctrl0 + s->num_cs) {
+ s->regs[addr] = value;
+ aspeed_smc_update_cs(s);
+ } else {
qemu_log_mask(LOG_UNIMP, "%s: not implemented: 0x%" HWADDR_PRIx "\n",
__func__, addr);
return;
}
-
- /*
- * Not much to do apart from storing the value and set the cs
- * lines if the register is a controlling one.
- */
- s->regs[addr] = value;
- if (addr >= s->r_ctrl0 && addr < s->r_ctrl0 + s->num_cs) {
- aspeed_smc_update_cs(s);
- }
}
static const MemoryRegionOps aspeed_smc_ops = {
--
2.1.4
next prev parent reply other threads:[~2016-07-08 16:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-08 16:06 [Qemu-devel] [PATCH 0/5] ast2400: some cleanups and a simple memory controller model Cédric Le Goater
2016-07-08 16:06 ` [Qemu-devel] [PATCH 1/5] hw/misc: fix typo in Aspeed SCU hw-strap2 property name Cédric Le Goater
2016-07-08 16:06 ` Cédric Le Goater [this message]
2016-07-08 16:06 ` [Qemu-devel] [PATCH 3/5] ast2400: pretend DMAs are done for U-boot Cédric Le Goater
2016-07-08 16:06 ` [Qemu-devel] [PATCH 4/5] ast2400: externalize revision numbers Cédric Le Goater
2016-07-08 16:06 ` [Qemu-devel] [PATCH 5/5] ast2400: add a memory controller device model Cédric Le Goater
2016-07-25 15:12 ` Peter Maydell
2016-07-25 15:55 ` Cédric Le Goater
2016-07-12 14:19 ` [Qemu-devel] [PATCH 0/5] ast2400: some cleanups and a simple memory controller model Peter Maydell
2016-07-12 16:20 ` Cédric Le Goater
2016-07-12 16:32 ` Cédric Le Goater
2016-07-12 17:10 ` Peter Maydell
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=1467994016-11678-3-git-send-email-clg@kaod.org \
--to=clg@kaod.org \
--cc=andrew@aj.id.au \
--cc=crosthwaite.peter@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).