All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-trivial] [PATCH Trivial] hw/intc/arm_gic: Use pre-defined macro for cpu_num in code
@ 2015-11-05 15:12 ` Wei Huang
  0 siblings, 0 replies; 7+ messages in thread
From: Wei Huang @ 2015-11-05 15:12 UTC (permalink / raw)
  To: qemu-arm; +Cc: qemu-trivial, peter.maydell, afaerber

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.

Signed-off-by: Wei Huang <wei@redhat.com>
---
 hw/intc/arm_gic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
index 8bad132..4e7733c 100644
--- a/hw/intc/arm_gic.c
+++ b/hw/intc/arm_gic.c
@@ -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;
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-arm] [PATCH Trivial] hw/intc/arm_gic: Use pre-defined macro for cpu_num in code
@ 2015-11-05 15:12 ` Wei Huang
  0 siblings, 0 replies; 7+ messages in thread
From: Wei Huang @ 2015-11-05 15:12 UTC (permalink / raw)
  To: qemu-arm; +Cc: qemu-trivial, afaerber

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.

Signed-off-by: Wei Huang <wei@redhat.com>
---
 hw/intc/arm_gic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
index 8bad132..4e7733c 100644
--- a/hw/intc/arm_gic.c
+++ b/hw/intc/arm_gic.c
@@ -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;
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-trivial] [PATCH Trivial] hw/intc/arm_gic: Use pre-defined macro for cpu_num in code
  2015-11-05 15:12 ` [Qemu-arm] " Wei Huang
@ 2015-11-05 15:31   ` Peter Maydell
  -1 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2015-11-05 15:31 UTC (permalink / raw)
  To: Wei Huang; +Cc: QEMU Trivial, qemu-arm, Andreas Färber, QEMU Developers

On 5 November 2015 at 15:12, Wei Huang <wei@redhat.com> wrote:
> 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.

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH Trivial] hw/intc/arm_gic: Use pre-defined macro for cpu_num in code
@ 2015-11-05 15:31   ` Peter Maydell
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2015-11-05 15:31 UTC (permalink / raw)
  To: Wei Huang; +Cc: QEMU Trivial, qemu-arm, Andreas Färber, QEMU Developers

On 5 November 2015 at 15:12, Wei Huang <wei@redhat.com> wrote:
> 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.

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-trivial] [PATCH Trivial] hw/intc/arm_gic: Use pre-defined macro for cpu_num in code
  2015-11-05 15:31   ` [Qemu-devel] " Peter Maydell
  (?)
@ 2015-11-05 16:55     ` Wei Huang
  -1 siblings, 0 replies; 7+ messages in thread
From: Wei Huang @ 2015-11-05 16:55 UTC (permalink / raw)
  To: Peter Maydell
  Cc: QEMU Trivial, qemu-arm, Andreas Färber, QEMU Developers



On 11/05/2015 09:31 AM, Peter Maydell wrote:
> On 5 November 2015 at 15:12, Wei Huang <wei@redhat.com> wrote:
>> 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.
> 
> Hi. I think that actually since the NUM_CPU is 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

> 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
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-arm] [PATCH Trivial] hw/intc/arm_gic: Use pre-defined macro for cpu_num in code
@ 2015-11-05 16:55     ` Wei Huang
  0 siblings, 0 replies; 7+ messages in thread
From: Wei Huang @ 2015-11-05 16:55 UTC (permalink / raw)
  To: Peter Maydell
  Cc: QEMU Trivial, qemu-arm, Andreas Färber, QEMU Developers



On 11/05/2015 09:31 AM, Peter Maydell wrote:
> On 5 November 2015 at 15:12, Wei Huang <wei@redhat.com> wrote:
>> 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.
> 
> Hi. I think that actually since the NUM_CPU is 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

> 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
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH Trivial] hw/intc/arm_gic: Use pre-defined macro for cpu_num in code
@ 2015-11-05 16:55     ` Wei Huang
  0 siblings, 0 replies; 7+ messages in thread
From: Wei Huang @ 2015-11-05 16:55 UTC (permalink / raw)
  To: Peter Maydell
  Cc: QEMU Trivial, qemu-arm, Andreas Färber, QEMU Developers



On 11/05/2015 09:31 AM, Peter Maydell wrote:
> On 5 November 2015 at 15:12, Wei Huang <wei@redhat.com> wrote:
>> 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.
> 
> Hi. I think that actually since the NUM_CPU is 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

> 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
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-11-05 16:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-05 15:12 [Qemu-trivial] [PATCH Trivial] hw/intc/arm_gic: Use pre-defined macro for cpu_num in code Wei Huang
2015-11-05 15:12 ` [Qemu-arm] " Wei Huang
2015-11-05 15:31 ` [Qemu-trivial] " Peter Maydell
2015-11-05 15:31   ` [Qemu-devel] " Peter Maydell
2015-11-05 16:55   ` [Qemu-trivial] " Wei Huang
2015-11-05 16:55     ` [Qemu-devel] " Wei Huang
2015-11-05 16:55     ` [Qemu-arm] " Wei Huang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.