chip.c (30377642138aadeef35a31c2f90dba0b6fa7b91a) chip.c (b59f9f9775e643435bba76e30e59e47c19c56dee)
1/*
2 * IRQ chip definitions for INTC IRQs.
3 *
4 * Copyright (C) 2007, 2008 Magnus Damm
1/*
2 * IRQ chip definitions for INTC IRQs.
3 *
4 * Copyright (C) 2007, 2008 Magnus Damm
5 * Copyright (C) 2009, 2010 Paul Mundt
5 * Copyright (C) 2009 - 2012 Paul Mundt
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 */
11#include <linux/cpumask.h>
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 */
11#include <linux/cpumask.h>
12#include <linux/bsearch.h>
12#include <linux/io.h>
13#include "internals.h"
14
15void _intc_enable(struct irq_data *data, unsigned long handle)
16{
17 unsigned int irq = data->irq;
18 struct intc_desc_int *d = get_intc_desc(irq);
19 unsigned long addr;

--- 92 unchanged lines hidden (view full) ---

112 }
113 }
114}
115
116static struct intc_handle_int *intc_find_irq(struct intc_handle_int *hp,
117 unsigned int nr_hp,
118 unsigned int irq)
119{
13#include <linux/io.h>
14#include "internals.h"
15
16void _intc_enable(struct irq_data *data, unsigned long handle)
17{
18 unsigned int irq = data->irq;
19 struct intc_desc_int *d = get_intc_desc(irq);
20 unsigned long addr;

--- 92 unchanged lines hidden (view full) ---

113 }
114 }
115}
116
117static struct intc_handle_int *intc_find_irq(struct intc_handle_int *hp,
118 unsigned int nr_hp,
119 unsigned int irq)
120{
120 int i;
121 struct intc_handle_int key;
121
122
122 /*
123 * this doesn't scale well, but...
124 *
125 * this function should only be used for cerain uncommon
126 * operations such as intc_set_priority() and intc_set_type()
127 * and in those rare cases performance doesn't matter that much.
128 * keeping the memory footprint low is more important.
129 *
130 * one rather simple way to speed this up and still keep the
131 * memory footprint down is to make sure the array is sorted
132 * and then perform a bisect to lookup the irq.
133 */
134 for (i = 0; i < nr_hp; i++) {
135 if ((hp + i)->irq != irq)
136 continue;
123 key.irq = irq;
124 key.handle = 0;
137
125
138 return hp + i;
139 }
140
141 return NULL;
126 return bsearch(&key, hp, nr_hp, sizeof(*hp), intc_handle_int_cmp);
142}
143
144int intc_set_priority(unsigned int irq, unsigned int prio)
145{
146 struct intc_desc_int *d = get_intc_desc(irq);
147 struct irq_data *data = irq_get_irq_data(irq);
148 struct intc_handle_int *ihp;
149

--- 77 unchanged lines hidden ---
127}
128
129int intc_set_priority(unsigned int irq, unsigned int prio)
130{
131 struct intc_desc_int *d = get_intc_desc(irq);
132 struct irq_data *data = irq_get_irq_data(irq);
133 struct intc_handle_int *ihp;
134

--- 77 unchanged lines hidden ---