aboutsummaryrefslogtreecommitdiff
path: root/hw/char
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>2021-09-25 15:34:05 +0200
committerAlistair Francis <alistair.francis@wdc.com>2021-10-07 08:41:33 +1000
commit284a66a8f6ffc8a720071b3f3cbc10cff0637337 (patch)
treea3e451a25dd013f13b23c43ca975ed72cd74d3d0 /hw/char
parent6a03349007f84e514e2e3def25c3f85400fdb47a (diff)
downloadqemu-284a66a8f6ffc8a720071b3f3cbc10cff0637337.zip
qemu-284a66a8f6ffc8a720071b3f3cbc10cff0637337.tar.gz
qemu-284a66a8f6ffc8a720071b3f3cbc10cff0637337.tar.bz2
hw/char/mchp_pfsoc_mmuart: Simplify MCHP_PFSOC_MMUART_REG definition
The current MCHP_PFSOC_MMUART_REG_SIZE definition represent the size occupied by all the registers. However all registers are 32-bit wide, and the MemoryRegionOps handlers are restricted to 32-bit: static const MemoryRegionOps mchp_pfsoc_mmuart_ops = { .read = mchp_pfsoc_mmuart_read, .write = mchp_pfsoc_mmuart_write, .impl = { .min_access_size = 4, .max_access_size = 4, }, Avoid being triskaidekaphobic, simplify by using the number of registers. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Bin Meng <bin.meng@windriver.com> Tested-by: Bin Meng <bin.meng@windriver.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-id: 20210925133407.1259392-2-f4bug@amsat.org Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'hw/char')
-rw-r--r--hw/char/mchp_pfsoc_mmuart.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/hw/char/mchp_pfsoc_mmuart.c b/hw/char/mchp_pfsoc_mmuart.c
index 2facf85..584e7fe 100644
--- a/hw/char/mchp_pfsoc_mmuart.c
+++ b/hw/char/mchp_pfsoc_mmuart.c
@@ -29,13 +29,14 @@ static uint64_t mchp_pfsoc_mmuart_read(void *opaque, hwaddr addr, unsigned size)
{
MchpPfSoCMMUartState *s = opaque;
- if (addr >= MCHP_PFSOC_MMUART_REG_SIZE) {
+ addr >>= 2;
+ if (addr >= MCHP_PFSOC_MMUART_REG_COUNT) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: read: addr=0x%" HWADDR_PRIx "\n",
- __func__, addr);
+ __func__, addr << 2);
return 0;
}
- return s->reg[addr / sizeof(uint32_t)];
+ return s->reg[addr];
}
static void mchp_pfsoc_mmuart_write(void *opaque, hwaddr addr,
@@ -44,13 +45,14 @@ static void mchp_pfsoc_mmuart_write(void *opaque, hwaddr addr,
MchpPfSoCMMUartState *s = opaque;
uint32_t val32 = (uint32_t)value;
- if (addr >= MCHP_PFSOC_MMUART_REG_SIZE) {
+ addr >>= 2;
+ if (addr >= MCHP_PFSOC_MMUART_REG_COUNT) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: bad write: addr=0x%" HWADDR_PRIx
- " v=0x%x\n", __func__, addr, val32);
+ " v=0x%x\n", __func__, addr << 2, val32);
return;
}
- s->reg[addr / sizeof(uint32_t)] = val32;
+ s->reg[addr] = val32;
}
static const MemoryRegionOps mchp_pfsoc_mmuart_ops = {