aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/irq
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
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')
-rw-r--r--kernel/irq/chip.c49
-rw-r--r--kernel/irq/manage.c43
2 files changed, 54 insertions, 38 deletions
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 2aa3d4b2fce8..a4bb0da9c88c 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -27,13 +27,13 @@ void dynamic_irq_init(unsigned int irq)
27 struct irq_desc *desc; 27 struct irq_desc *desc;
28 unsigned long flags; 28 unsigned long flags;
29 29
30 if (irq >= nr_irqs) { 30 desc = irq_to_desc(irq);
31 if (!desc) {
31 WARN(1, KERN_ERR "Trying to initialize invalid IRQ%d\n", irq); 32 WARN(1, KERN_ERR "Trying to initialize invalid IRQ%d\n", irq);
32 return; 33 return;
33 } 34 }
34 35
35 /* Ensure we don't have left over values from a previous use of this irq */ 36 /* Ensure we don't have left over values from a previous use of this irq */
36 desc = irq_to_desc(irq);
37 spin_lock_irqsave(&desc->lock, flags); 37 spin_lock_irqsave(&desc->lock, flags);
38 desc->status = IRQ_DISABLED; 38 desc->status = IRQ_DISABLED;
39 desc->chip = &no_irq_chip; 39 desc->chip = &no_irq_chip;
@@ -60,12 +60,12 @@ void dynamic_irq_cleanup(unsigned int irq)
60 struct irq_desc *desc; 60 struct irq_desc *desc;
61 unsigned long flags; 61 unsigned long flags;
62 62
63 if (irq >= nr_irqs) { 63 desc = __irq_to_desc(irq);
64 if (!desc) {
64 WARN(1, KERN_ERR "Trying to cleanup invalid IRQ%d\n", irq); 65 WARN(1, KERN_ERR "Trying to cleanup invalid IRQ%d\n", irq);
65 return; 66 return;
66 } 67 }
67 68
68 desc = irq_to_desc(irq);
69 spin_lock_irqsave(&desc->lock, flags); 69 spin_lock_irqsave(&desc->lock, flags);
70 if (desc->action) { 70 if (desc->action) {
71 spin_unlock_irqrestore(&desc->lock, flags); 71 spin_unlock_irqrestore(&desc->lock, flags);
@@ -92,7 +92,8 @@ int set_irq_chip(unsigned int irq, struct irq_chip *chip)
92 struct irq_desc *desc; 92 struct irq_desc *desc;
93 unsigned long flags; 93 unsigned long flags;
94 94
95 if (irq >= nr_irqs) { 95 desc = __irq_to_desc(irq);
96 if (!desc) {
96 WARN(1, KERN_ERR "Trying to install chip for IRQ%d\n", irq); 97 WARN(1, KERN_ERR "Trying to install chip for IRQ%d\n", irq);
97 return -EINVAL; 98 return -EINVAL;
98 } 99 }
@@ -121,12 +122,12 @@ int set_irq_type(unsigned int irq, unsigned int type)
121 unsigned long flags; 122 unsigned long flags;
122 int ret = -ENXIO; 123 int ret = -ENXIO;
123 124
124 if (irq >= nr_irqs) { 125 desc = __irq_to_desc(irq);
126 if (!desc) {
125 printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq); 127 printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq);
126 return -ENODEV; 128 return -ENODEV;
127 } 129 }
128 130
129 desc = irq_to_desc(irq);
130 if (type == IRQ_TYPE_NONE) 131 if (type == IRQ_TYPE_NONE)
131 return 0; 132 return 0;
132 133
@@ -149,13 +150,13 @@ int set_irq_data(unsigned int irq, void *data)
149 struct irq_desc *desc; 150 struct irq_desc *desc;
150 unsigned long flags; 151 unsigned long flags;
151 152
152 if (irq >= nr_irqs) { 153 desc = __irq_to_desc(irq);
154 if (!desc) {
153 printk(KERN_ERR 155 printk(KERN_ERR
154 "Trying to install controller data for IRQ%d\n", irq); 156 "Trying to install controller data for IRQ%d\n", irq);
155 return -EINVAL; 157 return -EINVAL;
156 } 158 }
157 159
158 desc = irq_to_desc(irq);
159 spin_lock_irqsave(&desc->lock, flags); 160 spin_lock_irqsave(&desc->lock, flags);
160 desc->handler_data = data; 161 desc->handler_data = data;
161 spin_unlock_irqrestore(&desc->lock, flags); 162 spin_unlock_irqrestore(&desc->lock, flags);
@@ -175,12 +176,13 @@ int set_irq_msi(unsigned int irq, struct msi_desc *entry)
175 struct irq_desc *desc; 176 struct irq_desc *desc;
176 unsigned long flags; 177 unsigned long flags;
177 178
178 if (irq >= nr_irqs) { 179 desc = __irq_to_desc(irq);
180 if (!desc) {
179 printk(KERN_ERR 181 printk(KERN_ERR
180 "Trying to install msi data for IRQ%d\n", irq); 182 "Trying to install msi data for IRQ%d\n", irq);
181 return -EINVAL; 183 return -EINVAL;
182 } 184 }
183 desc = irq_to_desc(irq); 185
184 spin_lock_irqsave(&desc->lock, flags); 186 spin_lock_irqsave(&desc->lock, flags);
185 desc->msi_desc = entry; 187 desc->msi_desc = entry;
186 if (entry) 188 if (entry)
@@ -201,8 +203,14 @@ int set_irq_chip_data(unsigned int irq, void *data)
201 struct irq_desc *desc; 203 struct irq_desc *desc;
202 unsigned long flags; 204 unsigned long flags;
203 205
204 desc = irq_to_desc(irq); 206 desc = __irq_to_desc(irq);
205 if (irq >= nr_irqs || !desc->chip) { 207 if (!desc) {
208 printk(KERN_ERR
209 "Trying to install chip data for IRQ%d\n", irq);
210 return -EINVAL;
211 }
212
213 if (!desc->chip) {
206 printk(KERN_ERR "BUG: bad set_irq_chip_data(IRQ#%d)\n", irq); 214 printk(KERN_ERR "BUG: bad set_irq_chip_data(IRQ#%d)\n", irq);
207 return -EINVAL; 215 return -EINVAL;
208 } 216 }
@@ -546,14 +554,13 @@ __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
546 struct irq_desc *desc; 554 struct irq_desc *desc;
547 unsigned long flags; 555 unsigned long flags;
548 556
549 if (irq >= nr_irqs) { 557 desc = __irq_to_desc(irq);
558 if (!desc) {
550 printk(KERN_ERR 559 printk(KERN_ERR
551 "Trying to install type control for IRQ%d\n", irq); 560 "Trying to install type control for IRQ%d\n", irq);
552 return; 561 return;
553 } 562 }
554 563
555 desc = irq_to_desc(irq);
556
557 if (!handle) 564 if (!handle)
558 handle = handle_bad_irq; 565 handle = handle_bad_irq;
559 else if (desc->chip == &no_irq_chip) { 566 else if (desc->chip == &no_irq_chip) {
@@ -611,14 +618,13 @@ void __init set_irq_noprobe(unsigned int irq)
611 struct irq_desc *desc; 618 struct irq_desc *desc;
612 unsigned long flags; 619 unsigned long flags;
613 620
614 if (irq >= nr_irqs) { 621 desc = __irq_to_desc(irq);
622 if (!desc) {
615 printk(KERN_ERR "Trying to mark IRQ%d non-probeable\n", irq); 623 printk(KERN_ERR "Trying to mark IRQ%d non-probeable\n", irq);
616 624
617 return; 625 return;
618 } 626 }
619 627
620 desc = irq_to_desc(irq);
621
622 spin_lock_irqsave(&desc->lock, flags); 628 spin_lock_irqsave(&desc->lock, flags);
623 desc->status |= IRQ_NOPROBE; 629 desc->status |= IRQ_NOPROBE;
624 spin_unlock_irqrestore(&desc->lock, flags); 630 spin_unlock_irqrestore(&desc->lock, flags);
@@ -629,14 +635,13 @@ void __init set_irq_probe(unsigned int irq)
629 struct irq_desc *desc; 635 struct irq_desc *desc;
630 unsigned long flags; 636 unsigned long flags;
631 637
632 if (irq >= nr_irqs) { 638 desc = __irq_to_desc(irq);
639 if (!desc) {
633 printk(KERN_ERR "Trying to mark IRQ%d probeable\n", irq); 640 printk(KERN_ERR "Trying to mark IRQ%d probeable\n", irq);
634 641
635 return; 642 return;
636 } 643 }
637 644
638 desc = irq_to_desc(irq);
639
640 spin_lock_irqsave(&desc->lock, flags); 645 spin_lock_irqsave(&desc->lock, flags);
641 desc->status &= ~IRQ_NOPROBE; 646 desc->status &= ~IRQ_NOPROBE;
642 spin_unlock_irqrestore(&desc->lock, flags); 647 spin_unlock_irqrestore(&desc->lock, flags);
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)