aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/irq/chip.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/chip.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/chip.c')
-rw-r--r--kernel/irq/chip.c49
1 files changed, 27 insertions, 22 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);