hw/arm/highbank: Simplify code (memory region in device state)
PATCH 1/1 hw/arm/highbank: Simplify code (memory region in device state)
The memory region can be included by value instead of by reference in the device state (like it is done in other SoCs).
--- hw/arm/highbank.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
hw/arm/highbank.c +3 -4
@@ -125,7 +125,7 @@ typedef struct {SysBusDevice parent_obj;/*< public >*/ -MemoryRegion *iomem; +MemoryRegion iomem;uint32_t regs[NUM_REGS ]; } HighbankRegsState;
@@ -154,10 +154,9 @@ static int highbank_regs_init(SysBusDevice *dev) {HighbankRegsState *s =HIGHBANK_REGISTERS (dev); - s->iomem =g_new (MemoryRegion,1 ); -memory_region_init_io (s->iomem,OBJECT (s), &hb_mem_ops, s->regs, +memory_region_init_io (&s->iomem,OBJECT (s), &hb_mem_ops, s->regs,"highbank_regs" ,0x1000 ); -sysbus_init_mmio (dev, s->iomem); +sysbus_init_mmio (dev, &s->iomem);return 0 ; }
Signature · 1 line
1.7.10.4
Quoted 13 lines · Stefan Weil
The memory region can be included by value instead of by reference in the device state (like it is done in other SoCs).
Signed-off-by Stefan Weil <[email protected]>--- hw/arm/highbank.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)hw/arm/highbank.c +0
-0
hw/arm/highbank.c typedef struct { · line 130
Quoted 7 lines
hw/arm/highbank.c +1
-1@@ -125,7 +125,7 @@ typedef struct {SysBusDevice parent_obj;/*< public >*/ -MemoryRegion *iomem; +MemoryRegion iomem;uint32_t regs[NUM_REGS ]; } HighbankRegsState;
Don't we have active maintainer for arm? (Who is Cc'd on the original patch).
hw/arm/highbank.c static int highbank_regs_init(SysBusDevice *dev) · line 158
Quoted 8 lines
hw/arm/highbank.c +1
-2@@ -154,10 +154,9 @@ static int highbank_regs_init(SysBusDevice *dev) {HighbankRegsState *s =HIGHBANK_REGISTERS (dev); - s->iomem =g_new (MemoryRegion,1 ); -memory_region_init_io (s->iomem,OBJECT (s), &hb_mem_ops, s->regs, +memory_region_init_io (&s->iomem,OBJECT (s), &hb_mem_ops, s->regs,"highbank_regs" ,0x1000 );
I know right to nothing about arm, does it have any alignment requiriments, which may break here?
Thanks,
/mjt
Peter Maydell
Reviewed-byQuoted 17 lines · Michael Tokarev
Quoted 16 lines · Stefan Weil
The memory region can be included by value instead of by reference in the device state (like it is done in other SoCs).
Signed-off-by Stefan Weil <[email protected]>--- hw/arm/highbank.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)hw/arm/highbank.c +0
-0@@ -125,7 +125,7 @@ typedef struct {SysBusDevice parent_obj;/*< public >*/
Quoted 6 lines
hw/arm/highbank.c typedef struct { · line 130
Quoted 4 lines
hw/arm/highbank.c +1
-1-MemoryRegion *iomem; +MemoryRegion iomem;uint32_t regs[NUM_REGS ]; } HighbankRegsState;Don't we have active maintainer for arm? (Who is Cc'd on the original patch).
Yeah, and there's highbank related patches currently going through review so it might be better for me to take this in the target-arm queue (though for a trivial one like this it doesn't make much difference).
Quoted 11 lines
hw/arm/highbank.c static int highbank_regs_init(SysBusDevice *dev) · line 158
Quoted 8 lines
hw/arm/highbank.c +1
-2@@ -154,10 +154,9 @@ static int highbank_regs_init(SysBusDevice *dev) {HighbankRegsState *s =HIGHBANK_REGISTERS (dev); - s->iomem =g_new (MemoryRegion,1 ); -memory_region_init_io (s->iomem,OBJECT (s), &hb_mem_ops, s->regs, +memory_region_init_io (&s->iomem,OBJECT (s), &hb_mem_ops, s->regs,"highbank_regs" ,0x1000 );I know right to nothing about arm, does it have any alignment requiriments, which may break here?
Hmm? This is just putting the MemoryRegion struct in the HighBankRegsState structure rather than allocating it via g_new(). That's all host related and in any case is the host C compiler's problem to deal with.
thanks
-- PMM
Peter Crosthwaite
Reviewed-byQuoted 4 lines · Peter Maydell
Quoted 3 lines · Michael Tokarev
Quoted 2 lines · Stefan Weil
The memory region can be included by value instead of by reference in the device state (like it is done in other SoCs).
So following on from the logic below you'd be best to just drop the parenthetic in the commit message. The change isn't exactly aligned to the current ARM SOCification efforts. Just the sentance on its own is enough motivation.
Quoted 37 lines
Quoted 14 lines
Quoted 14 lines
Signed-off-by Stefan Weil <[email protected]>--- hw/arm/highbank.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)hw/arm/highbank.c +0
-0@@ -125,7 +125,7 @@ typedef struct {SysBusDevice parent_obj;/*< public >*/ Quoted 6 lines
hw/arm/highbank.c typedef struct { · line 130
Quoted 4 lines
hw/arm/highbank.c +1
-1-MemoryRegion *iomem; +MemoryRegion iomem;uint32_t regs[NUM_REGS ]; } HighbankRegsState;Don't we have active maintainer for arm? (Who is Cc'd on the original patch).
Yeah, and there's highbank related patches currently going through review so it might be better for me to take this in the target-arm queue (though for a trivial one like this it doesn't make much difference).
Quoted 11 lines
hw/arm/highbank.c static int highbank_regs_init(SysBusDevice *dev) · line 158
Quoted 8 lines
hw/arm/highbank.c +1
-2@@ -154,10 +154,9 @@ static int highbank_regs_init(SysBusDevice *dev) {HighbankRegsState *s =HIGHBANK_REGISTERS (dev); - s->iomem =g_new (MemoryRegion,1 ); -memory_region_init_io (s->iomem,OBJECT (s), &hb_mem_ops, s->regs, +memory_region_init_io (&s->iomem,OBJECT (s), &hb_mem_ops, s->regs,"highbank_regs" ,0x1000 );I know right to nothing about arm, does it have any alignment requiriments, which may break here?
Quoted 4 lines
Hmm? This is just putting the MemoryRegion struct in the HighBankRegsState structure rather than allocating it via
g_new(). That's all host related and in any case is the host C compiler's problem to deal with.
So I guess the correct course of action (ultimately) is to:
A: Core-ify these registers.
B: Factor out all devices including Coreified regs into a SoC container.
The state struct being change here would correspond to the corified register block and not the SoC container.
But if you were to execute step A, you would make this change upon migration of the device state struct to the new device. The patch also simply stands in its own right as just the right thing to do. So.
Quoted 2 lines
Reviewed-by Peter Maydell <[email protected]>
Quoted 3 lines
thanks
-- PMM
Michael Tokarev
AppliedQuoted 2 lines · Stefan Weil
The memory region can be included by value instead of by reference in the device state (like it is done in other SoCs).
Applied to trivial-patches queue, with the suggested comment fix.
Thanks!
/mjt