hw/i2c/mpc_i2c.c: Fix mmio region size
PATCH 1/1 hw/i2c/mpc_i2c.c: Fix mmio region size
The last register of this device is at offset 0x14 occupying 8 bits so to cover it the mmio region needs to be 0x15 bytes long. Also correct the name of the field storing this register value to match the register name.
--- hw/i2c/mpc_i2c.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/i2c/mpc_i2c.c +4 -4
@@ -82,7 +82,7 @@ struct MPCI2CState {uint8_t cr;uint8_t sr;uint8_t dr; -uint8_t dfssr; +uint8_t dfsrr; };static bool mpc_i2c_is_enabled (MPCI2CState *s)
@@ -293,7 +293,7 @@ static void mpc_i2c_write(void *opaque, hwaddr addr, }break ;case MPC_I2C_DFSRR : - s->dfssr = value; + s->dfsrr = value;break ;default :DPRINTF ("ERROR: Bad write addr 0x%x\n" , (unsigned int )addr);
@@ -319,7 +319,7 @@ static const VMStateDescription mpc_i2c_vmstate = {VMSTATE_UINT8 (cr, MPCI2CState),VMSTATE_UINT8 (sr, MPCI2CState),VMSTATE_UINT8 (dr, MPCI2CState), -VMSTATE_UINT8 (dfssr, MPCI2CState), +VMSTATE_UINT8 (dfsrr, MPCI2CState), VMSTATE_END_OF_LIST() } };
@@ -329,7 +329,7 @@ static void mpc_i2c_realize(DeviceState *dev, Error **errp)MPCI2CState *i2c =MPC_I2C (dev);sysbus_init_irq (SYS_BUS_DEVICE (dev), &i2c->irq);memory_region_init_io (&i2c->iomem,OBJECT (i2c), &i2c_ops, i2c, -"mpc-i2c" ,0x14 ); +"mpc-i2c" ,0x15 );sysbus_init_mmio (SYS_BUS_DEVICE (dev), &i2c->iomem); i2c->bus =i2c_init_bus (dev,"i2c" ); }
Signature · 1 line
2.30.9
+Amit & Andrew
Quoted 12 lines · BALATON Zoltan
The last register of this device is at offset
0x14occupying 8 bits so to cover it the mmio region needs to be0x15bytes long. Also correct the name of the field storing this register value to match the register name.Signed-off-by BALATON Zoltan <[email protected]>--- hw/i2c/mpc_i2c.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/i2c/mpc_i2c.c static void mpc_i2c_realize(DeviceState *dev, Error **errp) · line 332
Quoted 5 lines
hw/i2c/mpc_i2c.c +1
-1@@ -329,7 +329,7 @@ static void mpc_i2c_realize(DeviceState *dev, Error **errp)MPCI2CState *i2c =MPC_I2C (dev);sysbus_init_irq (SYS_BUS_DEVICE (dev), &i2c->irq);memory_region_init_io (&i2c->iomem,OBJECT (i2c), &i2c_ops, i2c, -"mpc-i2c" ,0x14 ); +"mpc-i2c" ,0x15 );
Personally I'm not a big fan of non-pow2 regions, so I'd have picked 0x20 or 0x100 where the 2nd i2c controller starts. Amit, what do you think?
Anyhow,
Quoted 3 lines
hw/i2c/mpc_i2c.c +0
-0sysbus_init_mmio (SYS_BUS_DEVICE (dev), &i2c->iomem); i2c->bus =i2c_init_bus (dev,"i2c" ); }
Quoted 14 lines · Philippe Mathieu-Daudé
+Amit & Andrew
Quoted 9 lines · BALATON Zoltan
The last register of this device is at offset
0x14occupying 8 bits so to cover it the mmio region needs to be0x15bytes long. Also correct the name of the field storing this register value to match the register name.Signed-off-by BALATON Zoltan <[email protected]>--- hw/i2c/mpc_i2c.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Quoted 10 lines
hw/i2c/mpc_i2c.c static void mpc_i2c_realize(DeviceState *dev, Error · line 333
Quoted 7 lines
hw/i2c/mpc_i2c.c +1
-1@@ -329,7 +329,7 @@ static void mpc_i2c_realize(DeviceState *dev, Error **errp)MPCI2CState *i2c =MPC_I2C (dev);sysbus_init_irq (SYS_BUS_DEVICE (dev), &i2c->irq);memory_region_init_io (&i2c->iomem,OBJECT (i2c), &i2c_ops, i2c, -"mpc-i2c" ,0x14 ); +"mpc-i2c" ,0x15 );Personally I'm not a big fan of non-pow2 regions, so I'd have picked
0x20or0x100where the 2nd i2c controller starts. Amit, what do you
Coverung unused areas isn't a good idea because that would omit invalid read/write warnings when those are enabled so it's harder to catch unimplemented registers that way. So 0x100 is definitely overkill, 0x20 could be acceptable as other regs are also covering some unused area after them but is also unnecessary when we can cover exactly the area where the register is.
Regards,
BALATON Zoltan
Quoted 12 lines
think?
Anyhow,
Fixes 7abb479c7a ("PPC: E500: Add FSL I2C controller")Reviewed-by Philippe Mathieu-Daudé <[email protected]>Quoted 3 lines
hw/i2c/mpc_i2c.c +0
-0sysbus_init_mmio (SYS_BUS_DEVICE (dev), &i2c->iomem); i2c->bus =i2c_init_bus (dev,"i2c" );}
Quoted 26 lines · BALATON Zoltan
Quoted 14 lines · Philippe Mathieu-Daudé
+Amit & Andrew
Quoted 9 lines · BALATON Zoltan
The last register of this device is at offset
0x14occupying 8 bits so to cover it the mmio region needs to be0x15bytes long. Also correct the name of the field storing this register value to match the register name.Signed-off-by BALATON Zoltan <[email protected]>---
hw/i2c/mpc_i2c.c| 8 ++++----1 file changed, 4 insertions(+), 4 deletions(-)Quoted 10 lines
hw/i2c/mpc_i2c.c static void mpc_i2c_realize(DeviceState *dev, · line 333
Quoted 7 lines
hw/i2c/mpc_i2c.c +1
-1@@ -329,7 +329,7 @@ static void mpc_i2c_realize(DeviceState *dev, Error **errp) MPCI2CState *i2c = MPC_I2C(dev); sysbus_init_irq(SYS_BUS_DEVICE(dev), &i2c->irq); memory_region_init_io(&i2c->iomem, OBJECT(i2c), &i2c_ops, i2c, - "mpc-i2c", 0x14); + "mpc-i2c", 0x15);Personally I'm not a big fan of non-pow2 regions, so I'd have picked
0x20or0x100where the 2nd i2c controller starts. Amit, what do you
Quoted 1 line
Coverung unused areas isn't a good idea because that would omit invalid read/write warnings when those are enabled so it's harder to catch unimplemented registers that way. So
0x100is definitely overkill,0x20could be acceptable as other regs are also covering some unused area after them but is also unnecessary when we can cover exactly the area where the register is.
Yeah. I'm queuing this patch via hw-misc, thanks.