diff options
author | Yinghai Lu <yhlu.kernel@gmail.com> | 2008-08-19 23:50:10 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-16 10:52:32 -0400 |
commit | 9059d8fa4a3a9153da53da890039f7f956cc9d19 (patch) | |
tree | 142f12d7843a4000eb9be7dd8a4a933ce2955f72 | |
parent | 7f95ec9e4c12fd067febfd57532da1166d75d858 (diff) |
irq: add irq_desc_without_new
add an irq_desc accessor that will not allocate any sparse entry
but returns failure if there's no entry present.
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | include/linux/irq.h | 13 | ||||
-rw-r--r-- | kernel/irq/handle.c | 28 |
2 files changed, 37 insertions, 4 deletions
diff --git a/include/linux/irq.h b/include/linux/irq.h index cbf471aee1ce..c9ffef7c3b44 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h | |||
@@ -191,10 +191,23 @@ struct irq_desc { | |||
191 | } ____cacheline_internodealigned_in_smp; | 191 | } ____cacheline_internodealigned_in_smp; |
192 | 192 | ||
193 | extern struct irq_desc *irq_to_desc(unsigned int irq); | 193 | extern struct irq_desc *irq_to_desc(unsigned int irq); |
194 | extern struct irq_desc *__irq_to_desc(unsigned int irq); | ||
195 | |||
196 | #ifndef CONFIG_HAVE_SPARSE_IRQ | ||
197 | |||
194 | #ifndef CONFIG_HAVE_DYN_ARRAY | 198 | #ifndef CONFIG_HAVE_DYN_ARRAY |
195 | /* could be removed if we get rid of all irq_desc reference */ | 199 | /* could be removed if we get rid of all irq_desc reference */ |
196 | extern struct irq_desc irq_desc[NR_IRQS]; | 200 | extern struct irq_desc irq_desc[NR_IRQS]; |
201 | #else | ||
202 | extern struct irq_desc *irq_desc; | ||
197 | #endif | 203 | #endif |
204 | |||
205 | #else | ||
206 | |||
207 | extern struct irq_desc *sparse_irqs; | ||
208 | |||
209 | #endif | ||
210 | |||
198 | #define kstat_irqs_this_cpu(DESC) \ | 211 | #define kstat_irqs_this_cpu(DESC) \ |
199 | ((DESC)->kstat_irqs[smp_processor_id()]) | 212 | ((DESC)->kstat_irqs[smp_processor_id()]) |
200 | 213 | ||
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c index 1f346990f3f8..8e55dbe50afc 100644 --- a/kernel/irq/handle.c +++ b/kernel/irq/handle.c | |||
@@ -112,7 +112,6 @@ static void init_kstat_irqs(struct irq_desc *desc, int nr_desc, int nr) | |||
112 | } | 112 | } |
113 | } | 113 | } |
114 | 114 | ||
115 | |||
116 | static void __init init_work(void *data) | 115 | static void __init init_work(void *data) |
117 | { | 116 | { |
118 | struct dyn_array *da = data; | 117 | struct dyn_array *da = data; |
@@ -149,9 +148,27 @@ static int __init parse_nr_irq_desc(char *arg) | |||
149 | 148 | ||
150 | early_param("nr_irq_desc", parse_nr_irq_desc); | 149 | early_param("nr_irq_desc", parse_nr_irq_desc); |
151 | 150 | ||
152 | static struct irq_desc *sparse_irqs; | 151 | struct irq_desc *sparse_irqs; |
153 | DEFINE_DYN_ARRAY(sparse_irqs, sizeof(struct irq_desc), nr_irq_desc, PAGE_SIZE, init_work); | 152 | DEFINE_DYN_ARRAY(sparse_irqs, sizeof(struct irq_desc), nr_irq_desc, PAGE_SIZE, init_work); |
154 | 153 | ||
154 | struct irq_desc *__irq_to_desc(unsigned int irq) | ||
155 | { | ||
156 | struct irq_desc *desc; | ||
157 | |||
158 | BUG_ON(irq == -1U); | ||
159 | |||
160 | desc = &sparse_irqs[0]; | ||
161 | while (desc) { | ||
162 | if (desc->irq == irq) | ||
163 | return desc; | ||
164 | |||
165 | if (desc->irq == -1U) | ||
166 | return NULL; | ||
167 | |||
168 | desc = desc->next; | ||
169 | } | ||
170 | return NULL; | ||
171 | } | ||
155 | struct irq_desc *irq_to_desc(unsigned int irq) | 172 | struct irq_desc *irq_to_desc(unsigned int irq) |
156 | { | 173 | { |
157 | struct irq_desc *desc, *desc_pri; | 174 | struct irq_desc *desc, *desc_pri; |
@@ -208,8 +225,7 @@ struct irq_desc *irq_to_desc(unsigned int irq) | |||
208 | return desc; | 225 | return desc; |
209 | } | 226 | } |
210 | #else | 227 | #else |
211 | 228 | struct irq_desc *irq_desc; | |
212 | static struct irq_desc *irq_desc; | ||
213 | DEFINE_DYN_ARRAY(irq_desc, sizeof(struct irq_desc), nr_irqs, PAGE_SIZE, init_work); | 229 | DEFINE_DYN_ARRAY(irq_desc, sizeof(struct irq_desc), nr_irqs, PAGE_SIZE, init_work); |
214 | 230 | ||
215 | #endif | 231 | #endif |
@@ -239,6 +255,10 @@ struct irq_desc *irq_to_desc(unsigned int irq) | |||
239 | 255 | ||
240 | return NULL; | 256 | return NULL; |
241 | } | 257 | } |
258 | struct irq_desc *__irq_to_desc(unsigned int irq) | ||
259 | { | ||
260 | return irq_to_desc(irq); | ||
261 | } | ||
242 | #endif | 262 | #endif |
243 | 263 | ||
244 | /* | 264 | /* |