aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/irq/manage.c
diff options
context:
space:
mode:
authorYinghai Lu <yhlu.kernel@gmail.com>2008-08-19 23:50:14 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-16 10:52:50 -0400
commit7d94f7ca401dd7f445fda9a971a48aa5427b3e55 (patch)
tree8f4d4b73966fd0aa54df2da5bbcf67ea0a7ff43a /kernel/irq/manage.c
parent46b8214d12c274bd4265aae482ab7ffe69d94818 (diff)
irq: remove >= nr_irqs checking with config_have_sparse_irq
remove irq limit checks - nr_irqs is dynamic and we expand anytime. v2: fix checking about result irq_cfg_without_new, so could use msi again v3: use irq_desc_without_new to check irq is valid Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/irq/manage.c')
-rw-r--r--kernel/irq/manage.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 5070f55fdc16..c0b4d4df6de2 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -31,10 +31,10 @@ cpumask_t irq_default_affinity = CPU_MASK_ALL;
31 */ 31 */
32void synchronize_irq(unsigned int irq) 32void synchronize_irq(unsigned int irq)
33{ 33{
34 struct irq_desc *desc = irq_to_desc(irq); 34 struct irq_desc *desc = __irq_to_desc(irq);
35 unsigned int status; 35 unsigned int status;
36 36
37 if (irq >= nr_irqs) 37 if (!desc)
38 return; 38 return;
39 39
40 do { 40 do {
@@ -142,10 +142,11 @@ int irq_select_affinity(unsigned int irq)
142 */ 142 */
143void disable_irq_nosync(unsigned int irq) 143void disable_irq_nosync(unsigned int irq)
144{ 144{
145 struct irq_desc *desc = irq_to_desc(irq); 145 struct irq_desc *desc;
146 unsigned long flags; 146 unsigned long flags;
147 147
148 if (irq >= nr_irqs) 148 desc = __irq_to_desc(irq);
149 if (!desc)
149 return; 150 return;
150 151
151 spin_lock_irqsave(&desc->lock, flags); 152 spin_lock_irqsave(&desc->lock, flags);
@@ -171,9 +172,10 @@ EXPORT_SYMBOL(disable_irq_nosync);
171 */ 172 */
172void disable_irq(unsigned int irq) 173void disable_irq(unsigned int irq)
173{ 174{
174 struct irq_desc *desc = irq_to_desc(irq); 175 struct irq_desc *desc;
175 176
176 if (irq >= nr_irqs) 177 desc = __irq_to_desc(irq);
178 if (!desc)
177 return; 179 return;
178 180
179 disable_irq_nosync(irq); 181 disable_irq_nosync(irq);
@@ -213,10 +215,11 @@ static void __enable_irq(struct irq_desc *desc, unsigned int irq)
213 */ 215 */
214void enable_irq(unsigned int irq) 216void enable_irq(unsigned int irq)
215{ 217{
216 struct irq_desc *desc = irq_to_desc(irq); 218 struct irq_desc *desc;
217 unsigned long flags; 219 unsigned long flags;
218 220
219 if (irq >= nr_irqs) 221 desc = __irq_to_desc(irq);
222 if (!desc)
220 return; 223 return;
221 224
222 spin_lock_irqsave(&desc->lock, flags); 225 spin_lock_irqsave(&desc->lock, flags);
@@ -290,10 +293,14 @@ EXPORT_SYMBOL(set_irq_wake);
290 */ 293 */
291int can_request_irq(unsigned int irq, unsigned long irqflags) 294int can_request_irq(unsigned int irq, unsigned long irqflags)
292{ 295{
293 struct irq_desc *desc = irq_to_desc(irq); 296 struct irq_desc *desc;
294 struct irqaction *action; 297 struct irqaction *action;
295 298
296 if (irq >= nr_irqs || desc->status & IRQ_NOREQUEST) 299 desc = __irq_to_desc(irq);
300 if (!desc)
301 return 0;
302
303 if (desc->status & IRQ_NOREQUEST)
297 return 0; 304 return 0;
298 305
299 action = desc->action; 306 action = desc->action;
@@ -352,14 +359,15 @@ int __irq_set_trigger(struct irq_desc *desc, unsigned int irq,
352 */ 359 */
353int setup_irq(unsigned int irq, struct irqaction *new) 360int setup_irq(unsigned int irq, struct irqaction *new)
354{ 361{
355 struct irq_desc *desc = irq_to_desc(irq); 362 struct irq_desc *desc;
356 struct irqaction *old, **p; 363 struct irqaction *old, **p;
357 const char *old_name = NULL; 364 const char *old_name = NULL;
358 unsigned long flags; 365 unsigned long flags;
359 int shared = 0; 366 int shared = 0;
360 int ret; 367 int ret;
361 368
362 if (irq >= nr_irqs) 369 desc = __irq_to_desc(irq);
370 if (!desc)
363 return -EINVAL; 371 return -EINVAL;
364 372
365 if (desc->chip == &no_irq_chip) 373 if (desc->chip == &no_irq_chip)
@@ -518,10 +526,11 @@ void free_irq(unsigned int irq, void *dev_id)
518 unsigned long flags; 526 unsigned long flags;
519 527
520 WARN_ON(in_interrupt()); 528 WARN_ON(in_interrupt());
521 if (irq >= nr_irqs) 529
530 desc = __irq_to_desc(irq);
531 if (!desc)
522 return; 532 return;
523 533
524 desc = irq_to_desc(irq);
525 spin_lock_irqsave(&desc->lock, flags); 534 spin_lock_irqsave(&desc->lock, flags);
526 p = &desc->action; 535 p = &desc->action;
527 for (;;) { 536 for (;;) {
@@ -634,9 +643,11 @@ int request_irq(unsigned int irq, irq_handler_t handler,
634 */ 643 */
635 if ((irqflags & IRQF_SHARED) && !dev_id) 644 if ((irqflags & IRQF_SHARED) && !dev_id)
636 return -EINVAL; 645 return -EINVAL;
637 if (irq >= nr_irqs) 646
647 desc = __irq_to_desc(irq);
648 if (!desc)
638 return -EINVAL; 649 return -EINVAL;
639 desc = irq_to_desc(irq); 650
640 if (desc->status & IRQ_NOREQUEST) 651 if (desc->status & IRQ_NOREQUEST)
641 return -EINVAL; 652 return -EINVAL;
642 if (!handler) 653 if (!handler)