Patchwork [4/8] pseries: Cleanup duplications of ics_valid_irq() code

login
register
mail settings
Submitter David Gibson
Date Oct. 11, 2012, 11:47 a.m.
Message ID <1349956064-26709-5-git-send-email-david@gibson.dropbear.id.au>
Download mbox | patch
Permalink /patch/190877/
State New
Headers show

Comments

David Gibson - Oct. 11, 2012, 11:47 a.m.
A couple of places in xics.c open-coded the same logic as is already
implemented in ics_valid_irq().  This patch fixes the code duplication.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/xics.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Patch

diff --git a/hw/xics.c b/hw/xics.c
index db01fe3..6b08430 100644
--- a/hw/xics.c
+++ b/hw/xics.c
@@ -326,8 +326,7 @@  static void ics_eoi(struct ics_state *ics, int nr)
 
 qemu_irq xics_get_qirq(struct icp_state *icp, int irq)
 {
-    if ((irq < icp->ics->offset)
-        || (irq >= (icp->ics->offset + icp->ics->nr_irqs))) {
+    if (!ics_valid_irq(icp->ics, irq)) {
         return NULL;
     }
 
@@ -336,8 +335,7 @@  qemu_irq xics_get_qirq(struct icp_state *icp, int irq)
 
 void xics_set_irq_type(struct icp_state *icp, int irq, bool lsi)
 {
-    assert((irq >= icp->ics->offset)
-           && (irq < (icp->ics->offset + icp->ics->nr_irqs)));
+    assert(ics_valid_irq(icp->ics, irq));
 
     icp->ics->irqs[irq - icp->ics->offset].lsi = lsi;
 }