hw/intc/arm_gic: Use pre-defined macro for cpu_num in code
PATCH 1/1 hw/intc/arm_gic: Use pre-defined macro for cpu_num in code
Given that there is a macro, NUM_CPU(s), defined for CPU number in arm_gic.c, it is better to use it instead of using s->num_cpu in this file. Code is more consistent after this change.
--- hw/intc/arm_gic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/intc/arm_gic.c +3 -3
@@ -39,7 +39,7 @@ static const uint8_t gic_id[] = {static inline int gic_get_current_cpu (GICState *s) { -if (s->num_cpu >1 ) { +if (NUM_CPU (s) >1 ) {return current_cpu->cpu_index; }return 0 ;
@@ -643,7 +643,7 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs) res =gic_get_priority (s, cpu, irq, attrs); }else if (offset <0xc00 ) {/* Interrupt CPU Target. */ -if (s->num_cpu ==1 && s->revision !=REV_11MPCORE ) { +if (NUM_CPU (s) ==1 && s->revision !=REV_11MPCORE ) {/* For uniprocessor GICs these RAZ/WI */ res =0 ; }else {
@@ -863,7 +863,7 @@ static void gic_dist_writeb(void *opaque, hwaddr offset,/* Interrupt CPU Target. RAZ/WI on uniprocessor GICs, with the * annoying exception of the 11MPCore's GIC. */ -if (s->num_cpu !=1 || s->revision ==REV_11MPCORE ) { +if (NUM_CPU (s) !=1 || s->revision ==REV_11MPCORE ) { irq = (offset -0x800 ) +GIC_BASE_IRQ ;if (irq >= s->num_irq) { goto bad_reg;
Signature · 1 line
2.4.3
Quoted 3 lines · Wei Huang
Given that there is a macro,
NUM_CPU(s), defined for CPU number inarm_gic.c, it is better to use it instead of usings->num_cpuin this file. Code is more consistent after this change.
Hi. I think that actually since the NUM_CPU is just a relic from when it used to possibly defined as something other than s->num_cpu, we should go in the opposite direction, and remove the macro entirely in favour of just using s->num_cpu directly.
(PS: you forgot to cc qemu-devel.)
thanks
-- PMM
Quoted 6 lines · Peter Maydell
Quoted 3 lines · Wei Huang
Given that there is a macro,
NUM_CPU(s), defined for CPU number inarm_gic.c, it is better to use it instead of usings->num_cpuin this file. Code is more consistent after this change.Hi. I think that actually since the
NUM_CPUis just a relic from
Looks like the relic was from c988bfadc9cab. I prefer macro for this case; but will fix based on your comments.
Thanks,
-Wei
Quoted 9 lines
when it used to possibly defined as something other than
s->num_cpu, we should go in the opposite direction, and remove the macro entirely in favour of just usings->num_cpudirectly.(PS: you forgot to cc qemu-devel.)
thanks
-- PMM