From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933582AbaFLL41 (ORCPT ); Thu, 12 Jun 2014 07:56:27 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:58205 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933545AbaFLL4V (ORCPT ); Thu, 12 Jun 2014 07:56:21 -0400 From: Sricharan R To: , , , CC: , , , , , , , Subject: [PATCH V2 05/19] irqchip: crossbar: Change allocation logic by reversing search for free irqs Date: Thu, 12 Jun 2014 17:23:13 +0530 Message-ID: <1402574007-13987-6-git-send-email-r.sricharan@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1402574007-13987-1-git-send-email-r.sricharan@ti.com> References: <1402574007-13987-1-git-send-email-r.sricharan@ti.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nishanth Menon Reverse the search algorithm to ensure that address mapping and IRQ allocation logics are proper. This can open up new bugs which are easily fixable rather than wait till allocation logic approaches the limit to find new bugs. Signed-off-by: Nishanth Menon Signed-off-by: Sricharan R Signed-off-by: Tony Lindgren --- drivers/irqchip/irq-crossbar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-crossbar.c b/drivers/irqchip/irq-crossbar.c index 287d3ce..de021638 100644 --- a/drivers/irqchip/irq-crossbar.c +++ b/drivers/irqchip/irq-crossbar.c @@ -68,7 +68,7 @@ static inline int get_prev_map_irq(int cb_no) { int i; - for (i = 0; i < cb->int_max; i++) + for (i = cb->int_max - 1; i >= 0; i--) if (cb->irq_map[i] == cb_no) return i; @@ -79,7 +79,7 @@ static inline int allocate_free_irq(int cb_no) { int i; - for (i = 0; i < cb->int_max; i++) { + for (i = cb->int_max - 1; i >= 0; i--) { if (cb->irq_map[i] == IRQ_FREE) { cb->irq_map[i] = cb_no; return i; -- 1.7.9.5