aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/sh/intc/chip.c
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2012-01-24 17:41:55 +0900
committerPaul Mundt <lethal@linux-sh.org>2012-01-24 17:41:55 +0900
commitb59f9f9775e643435bba76e30e59e47c19c56dee (patch)
tree55bc067e5d2da0fc01ef9808ded60d9234dde165 /drivers/sh/intc/chip.c
parentsh: intc: Use IRQ_SET_MASK_OK_NOCOPY for intc_set_affinity. (diff)
downloadlinux-dev-b59f9f9775e643435bba76e30e59e47c19c56dee.tar.xz
linux-dev-b59f9f9775e643435bba76e30e59e47c19c56dee.zip
sh: intc: optimize intc IRQ lookup
This ensures that the sense/prio lists are sorted at registration time, enabling us to use a simple binary search for an optimized lookup (something that had been on the TODO for some time). Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers/sh/intc/chip.c')
-rw-r--r--drivers/sh/intc/chip.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/drivers/sh/intc/chip.c b/drivers/sh/intc/chip.c
index db10adf63dd7..012df2676a26 100644
--- a/drivers/sh/intc/chip.c
+++ b/drivers/sh/intc/chip.c
@@ -2,13 +2,14 @@
* IRQ chip definitions for INTC IRQs.
*
* Copyright (C) 2007, 2008 Magnus Damm
- * Copyright (C) 2009, 2010 Paul Mundt
+ * Copyright (C) 2009 - 2012 Paul Mundt
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*/
#include <linux/cpumask.h>
+#include <linux/bsearch.h>
#include <linux/io.h>
#include "internals.h"
@@ -117,28 +118,12 @@ static struct intc_handle_int *intc_find_irq(struct intc_handle_int *hp,
unsigned int nr_hp,
unsigned int irq)
{
- int i;
-
- /*
- * this doesn't scale well, but...
- *
- * this function should only be used for cerain uncommon
- * operations such as intc_set_priority() and intc_set_type()
- * and in those rare cases performance doesn't matter that much.
- * keeping the memory footprint low is more important.
- *
- * one rather simple way to speed this up and still keep the
- * memory footprint down is to make sure the array is sorted
- * and then perform a bisect to lookup the irq.
- */
- for (i = 0; i < nr_hp; i++) {
- if ((hp + i)->irq != irq)
- continue;
+ struct intc_handle_int key;
- return hp + i;
- }
+ key.irq = irq;
+ key.handle = 0;
- return NULL;
+ return bsearch(&key, hp, nr_hp, sizeof(*hp), intc_handle_int_cmp);
}
int intc_set_priority(unsigned int irq, unsigned int prio)