diff options
author | Yinghai Lu <yhlu.kernel@gmail.com> | 2008-08-19 23:49:48 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-16 10:52:05 -0400 |
commit | 0799e432acfda879eaeef9622426bfa1434f3786 (patch) | |
tree | bc9a1d07438c52df08ab1e283ccd0a191b5fe05d /arch/x86/kernel/io_apic_64.c | |
parent | 85c0f90978bf50596dbd23854648020f1f9b5bfd (diff) |
x86: use nr_irqs
also add first_free_entry and pin_map_size, which were NR_IRQS derived
constants.
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/io_apic_64.c')
-rw-r--r-- | arch/x86/kernel/io_apic_64.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/arch/x86/kernel/io_apic_64.c b/arch/x86/kernel/io_apic_64.c index 02063ae042f7..448384c7c1e8 100644 --- a/arch/x86/kernel/io_apic_64.c +++ b/arch/x86/kernel/io_apic_64.c | |||
@@ -132,6 +132,7 @@ DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES); | |||
132 | #define MAX_PLUS_SHARED_IRQS NR_IRQS | 132 | #define MAX_PLUS_SHARED_IRQS NR_IRQS |
133 | #define PIN_MAP_SIZE (MAX_PLUS_SHARED_IRQS + NR_IRQS) | 133 | #define PIN_MAP_SIZE (MAX_PLUS_SHARED_IRQS + NR_IRQS) |
134 | 134 | ||
135 | int pin_map_size = PIN_MAP_SIZE; | ||
135 | /* | 136 | /* |
136 | * This is performance-critical, we want to do it O(1) | 137 | * This is performance-critical, we want to do it O(1) |
137 | * | 138 | * |
@@ -224,7 +225,7 @@ static inline void io_apic_sync(unsigned int apic) | |||
224 | int pin; \ | 225 | int pin; \ |
225 | struct irq_pin_list *entry = irq_2_pin + irq; \ | 226 | struct irq_pin_list *entry = irq_2_pin + irq; \ |
226 | \ | 227 | \ |
227 | BUG_ON(irq >= NR_IRQS); \ | 228 | BUG_ON(irq >= nr_irqs); \ |
228 | for (;;) { \ | 229 | for (;;) { \ |
229 | unsigned int reg; \ | 230 | unsigned int reg; \ |
230 | pin = entry->pin; \ | 231 | pin = entry->pin; \ |
@@ -301,7 +302,7 @@ static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, u8 vector) | |||
301 | int apic, pin; | 302 | int apic, pin; |
302 | struct irq_pin_list *entry = irq_2_pin + irq; | 303 | struct irq_pin_list *entry = irq_2_pin + irq; |
303 | 304 | ||
304 | BUG_ON(irq >= NR_IRQS); | 305 | BUG_ON(irq >= nr_irqs); |
305 | for (;;) { | 306 | for (;;) { |
306 | unsigned int reg; | 307 | unsigned int reg; |
307 | apic = entry->apic; | 308 | apic = entry->apic; |
@@ -358,19 +359,19 @@ static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t mask) | |||
358 | * shared ISA-space IRQs, so we have to support them. We are super | 359 | * shared ISA-space IRQs, so we have to support them. We are super |
359 | * fast in the common case, and fast for shared ISA-space IRQs. | 360 | * fast in the common case, and fast for shared ISA-space IRQs. |
360 | */ | 361 | */ |
362 | int first_free_entry = NR_IRQS; | ||
361 | static void add_pin_to_irq(unsigned int irq, int apic, int pin) | 363 | static void add_pin_to_irq(unsigned int irq, int apic, int pin) |
362 | { | 364 | { |
363 | static int first_free_entry = NR_IRQS; | ||
364 | struct irq_pin_list *entry = irq_2_pin + irq; | 365 | struct irq_pin_list *entry = irq_2_pin + irq; |
365 | 366 | ||
366 | BUG_ON(irq >= NR_IRQS); | 367 | BUG_ON(irq >= nr_irqs); |
367 | while (entry->next) | 368 | while (entry->next) |
368 | entry = irq_2_pin + entry->next; | 369 | entry = irq_2_pin + entry->next; |
369 | 370 | ||
370 | if (entry->pin != -1) { | 371 | if (entry->pin != -1) { |
371 | entry->next = first_free_entry; | 372 | entry->next = first_free_entry; |
372 | entry = irq_2_pin + entry->next; | 373 | entry = irq_2_pin + entry->next; |
373 | if (++first_free_entry >= PIN_MAP_SIZE) | 374 | if (++first_free_entry >= pin_map_size) |
374 | panic("io_apic.c: ran out of irq_2_pin entries!"); | 375 | panic("io_apic.c: ran out of irq_2_pin entries!"); |
375 | } | 376 | } |
376 | entry->apic = apic; | 377 | entry->apic = apic; |
@@ -634,7 +635,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin) | |||
634 | best_guess = irq; | 635 | best_guess = irq; |
635 | } | 636 | } |
636 | } | 637 | } |
637 | BUG_ON(best_guess >= NR_IRQS); | 638 | BUG_ON(best_guess >= nr_irqs); |
638 | return best_guess; | 639 | return best_guess; |
639 | } | 640 | } |
640 | 641 | ||
@@ -766,7 +767,7 @@ static int pin_2_irq(int idx, int apic, int pin) | |||
766 | irq += nr_ioapic_registers[i++]; | 767 | irq += nr_ioapic_registers[i++]; |
767 | irq += pin; | 768 | irq += pin; |
768 | } | 769 | } |
769 | BUG_ON(irq >= NR_IRQS); | 770 | BUG_ON(irq >= nr_irqs); |
770 | return irq; | 771 | return irq; |
771 | } | 772 | } |
772 | 773 | ||
@@ -801,7 +802,7 @@ static int __assign_irq_vector(int irq, cpumask_t mask) | |||
801 | int cpu; | 802 | int cpu; |
802 | struct irq_cfg *cfg; | 803 | struct irq_cfg *cfg; |
803 | 804 | ||
804 | BUG_ON((unsigned)irq >= NR_IRQS); | 805 | BUG_ON((unsigned)irq >= nr_irqs); |
805 | cfg = &irq_cfg[irq]; | 806 | cfg = &irq_cfg[irq]; |
806 | 807 | ||
807 | /* Only try and allocate irqs on cpus that are present */ | 808 | /* Only try and allocate irqs on cpus that are present */ |
@@ -875,7 +876,7 @@ static void __clear_irq_vector(int irq) | |||
875 | cpumask_t mask; | 876 | cpumask_t mask; |
876 | int cpu, vector; | 877 | int cpu, vector; |
877 | 878 | ||
878 | BUG_ON((unsigned)irq >= NR_IRQS); | 879 | BUG_ON((unsigned)irq >= nr_irqs); |
879 | cfg = &irq_cfg[irq]; | 880 | cfg = &irq_cfg[irq]; |
880 | BUG_ON(!cfg->vector); | 881 | BUG_ON(!cfg->vector); |
881 | 882 | ||
@@ -895,7 +896,7 @@ void __setup_vector_irq(int cpu) | |||
895 | int irq, vector; | 896 | int irq, vector; |
896 | 897 | ||
897 | /* Mark the inuse vectors */ | 898 | /* Mark the inuse vectors */ |
898 | for (irq = 0; irq < NR_IRQS; ++irq) { | 899 | for (irq = 0; irq < nr_irqs; ++irq) { |
899 | if (!cpu_isset(cpu, irq_cfg[irq].domain)) | 900 | if (!cpu_isset(cpu, irq_cfg[irq].domain)) |
900 | continue; | 901 | continue; |
901 | vector = irq_cfg[irq].vector; | 902 | vector = irq_cfg[irq].vector; |
@@ -1193,7 +1194,7 @@ __apicdebuginit(void) print_IO_APIC(void) | |||
1193 | } | 1194 | } |
1194 | } | 1195 | } |
1195 | printk(KERN_DEBUG "IRQ to pin mappings:\n"); | 1196 | printk(KERN_DEBUG "IRQ to pin mappings:\n"); |
1196 | for (i = 0; i < NR_IRQS; i++) { | 1197 | for (i = 0; i < nr_irqs; i++) { |
1197 | struct irq_pin_list *entry = irq_2_pin + i; | 1198 | struct irq_pin_list *entry = irq_2_pin + i; |
1198 | if (entry->pin < 0) | 1199 | if (entry->pin < 0) |
1199 | continue; | 1200 | continue; |
@@ -1366,7 +1367,7 @@ void __init enable_IO_APIC(void) | |||
1366 | int i, apic; | 1367 | int i, apic; |
1367 | unsigned long flags; | 1368 | unsigned long flags; |
1368 | 1369 | ||
1369 | for (i = 0; i < PIN_MAP_SIZE; i++) { | 1370 | for (i = 0; i < pin_map_size; i++) { |
1370 | irq_2_pin[i].pin = -1; | 1371 | irq_2_pin[i].pin = -1; |
1371 | irq_2_pin[i].next = 0; | 1372 | irq_2_pin[i].next = 0; |
1372 | } | 1373 | } |
@@ -1658,7 +1659,7 @@ static void ir_irq_migration(struct work_struct *work) | |||
1658 | { | 1659 | { |
1659 | int irq; | 1660 | int irq; |
1660 | 1661 | ||
1661 | for (irq = 0; irq < NR_IRQS; irq++) { | 1662 | for (irq = 0; irq < nr_irqs; irq++) { |
1662 | struct irq_desc *desc = irq_desc + irq; | 1663 | struct irq_desc *desc = irq_desc + irq; |
1663 | if (desc->status & IRQ_MOVE_PENDING) { | 1664 | if (desc->status & IRQ_MOVE_PENDING) { |
1664 | unsigned long flags; | 1665 | unsigned long flags; |
@@ -1707,7 +1708,7 @@ asmlinkage void smp_irq_move_cleanup_interrupt(void) | |||
1707 | struct irq_desc *desc; | 1708 | struct irq_desc *desc; |
1708 | struct irq_cfg *cfg; | 1709 | struct irq_cfg *cfg; |
1709 | irq = __get_cpu_var(vector_irq)[vector]; | 1710 | irq = __get_cpu_var(vector_irq)[vector]; |
1710 | if (irq >= NR_IRQS) | 1711 | if (irq >= nr_irqs) |
1711 | continue; | 1712 | continue; |
1712 | 1713 | ||
1713 | desc = irq_desc + irq; | 1714 | desc = irq_desc + irq; |
@@ -1865,7 +1866,7 @@ static inline void init_IO_APIC_traps(void) | |||
1865 | * Also, we've got to be careful not to trash gate | 1866 | * Also, we've got to be careful not to trash gate |
1866 | * 0x80, because int 0x80 is hm, kind of importantish. ;) | 1867 | * 0x80, because int 0x80 is hm, kind of importantish. ;) |
1867 | */ | 1868 | */ |
1868 | for (irq = 0; irq < NR_IRQS ; irq++) { | 1869 | for (irq = 0; irq < nr_irqs ; irq++) { |
1869 | if (IO_APIC_IRQ(irq) && !irq_cfg[irq].vector) { | 1870 | if (IO_APIC_IRQ(irq) && !irq_cfg[irq].vector) { |
1870 | /* | 1871 | /* |
1871 | * Hmm.. We don't have an entry for this, | 1872 | * Hmm.. We don't have an entry for this, |
@@ -2279,7 +2280,7 @@ int create_irq(void) | |||
2279 | 2280 | ||
2280 | irq = -ENOSPC; | 2281 | irq = -ENOSPC; |
2281 | spin_lock_irqsave(&vector_lock, flags); | 2282 | spin_lock_irqsave(&vector_lock, flags); |
2282 | for (new = (NR_IRQS - 1); new >= 0; new--) { | 2283 | for (new = (nr_irqs - 1); new >= 0; new--) { |
2283 | if (platform_legacy_irq(new)) | 2284 | if (platform_legacy_irq(new)) |
2284 | continue; | 2285 | continue; |
2285 | if (irq_cfg[new].vector != 0) | 2286 | if (irq_cfg[new].vector != 0) |