From patchwork Thu Oct 18 05:50:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 192199 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0C7C02C0098 for ; Thu, 18 Oct 2012 18:15:57 +1100 (EST) Received: from localhost ([::1]:38525 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOj03-0006nB-Vn for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2012 01:50:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOizG-0005OI-Aw for qemu-devel@nongnu.org; Thu, 18 Oct 2012 01:49:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOizF-0007d5-2Q for qemu-devel@nongnu.org; Thu, 18 Oct 2012 01:49:42 -0400 Received: from ozlabs.org ([203.10.76.45]:47940) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOizE-0007cX-Nd; Thu, 18 Oct 2012 01:49:40 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 182E42C00A5; Thu, 18 Oct 2012 16:49:34 +1100 (EST) From: David Gibson To: agraf@suse.de Date: Thu, 18 Oct 2012 16:50:29 +1100 Message-Id: <1350539437-535-8-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1350539437-535-1-git-send-email-david@gibson.dropbear.id.au> References: <1350539437-535-1-git-send-email-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 203.10.76.45 Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson Subject: [Qemu-devel] [PATCH 07/15] pseries: Cleanup duplications of ics_valid_irq() code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- hw/xics.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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; }