irq: introduce nr_irqs

at this point nr_irqs is equal NR_IRQS

convert a few easy users from NR_IRQS to dynamic nr_irqs.

v2: according to Eric, we need to take care of arch without generic_hardirqs

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
Yinghai Lu 2008-08-19 20:49:47 -07:00 committed by Ingo Molnar
parent 6da55c3e8d
commit 85c0f90978
11 changed files with 39 additions and 29 deletions

View File

@ -46,6 +46,8 @@
#include <asm/q40ints.h> #include <asm/q40ints.h>
#endif #endif
int nr_irqs = NR_IRQS;
extern u32 auto_irqhandler_fixup[]; extern u32 auto_irqhandler_fixup[];
extern u32 user_irqhandler_fixup[]; extern u32 user_irqhandler_fixup[];
extern u16 user_irqvec_fixup[]; extern u16 user_irqvec_fixup[];

View File

@ -17,6 +17,8 @@
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/profile.h> #include <linux/profile.h>
int nr_irqs = NR_IRQS;
/* /*
* show_interrupts is needed by /proc/interrupts. * show_interrupts is needed by /proc/interrupts.
*/ */

View File

@ -55,6 +55,9 @@
#define SMP_NOP2 #define SMP_NOP2
#define SMP_NOP3 #define SMP_NOP3
#endif /* SMP */ #endif /* SMP */
int nr_irqs = NR_IRQS;
unsigned long __raw_local_irq_save(void) unsigned long __raw_local_irq_save(void)
{ {
unsigned long retval; unsigned long retval;

View File

@ -15,6 +15,8 @@
#include <asm/ptrace.h> #include <asm/ptrace.h>
#include <asm/system.h> #include <asm/system.h>
extern int nr_irqs;
/* /*
* These correspond to the IORESOURCE_IRQ_* defines in * These correspond to the IORESOURCE_IRQ_* defines in
* linux/ioport.h to select the interrupt line behaviour. When * linux/ioport.h to select the interrupt line behaviour. When

View File

@ -38,7 +38,7 @@ unsigned long probe_irq_on(void)
* something may have generated an irq long ago and we want to * something may have generated an irq long ago and we want to
* flush such a longstanding irq before considering it as spurious. * flush such a longstanding irq before considering it as spurious.
*/ */
for (i = NR_IRQS-1; i > 0; i--) { for (i = nr_irqs-1; i > 0; i--) {
desc = irq_desc + i; desc = irq_desc + i;
spin_lock_irq(&desc->lock); spin_lock_irq(&desc->lock);
@ -68,7 +68,7 @@ unsigned long probe_irq_on(void)
* (we must startup again here because if a longstanding irq * (we must startup again here because if a longstanding irq
* happened in the previous stage, it may have masked itself) * happened in the previous stage, it may have masked itself)
*/ */
for (i = NR_IRQS-1; i > 0; i--) { for (i = nr_irqs-1; i > 0; i--) {
desc = irq_desc + i; desc = irq_desc + i;
spin_lock_irq(&desc->lock); spin_lock_irq(&desc->lock);
@ -89,7 +89,7 @@ unsigned long probe_irq_on(void)
* Now filter out any obviously spurious interrupts * Now filter out any obviously spurious interrupts
*/ */
mask = 0; mask = 0;
for (i = 0; i < NR_IRQS; i++) { for (i = 0; i < nr_irqs; i++) {
unsigned int status; unsigned int status;
desc = irq_desc + i; desc = irq_desc + i;
@ -130,7 +130,7 @@ unsigned int probe_irq_mask(unsigned long val)
int i; int i;
mask = 0; mask = 0;
for (i = 0; i < NR_IRQS; i++) { for (i = 0; i < nr_irqs; i++) {
struct irq_desc *desc = irq_desc + i; struct irq_desc *desc = irq_desc + i;
unsigned int status; unsigned int status;
@ -173,7 +173,7 @@ int probe_irq_off(unsigned long val)
{ {
int i, irq_found = 0, nr_irqs = 0; int i, irq_found = 0, nr_irqs = 0;
for (i = 0; i < NR_IRQS; i++) { for (i = 0; i < nr_irqs; i++) {
struct irq_desc *desc = irq_desc + i; struct irq_desc *desc = irq_desc + i;
unsigned int status; unsigned int status;

View File

@ -27,7 +27,7 @@ void dynamic_irq_init(unsigned int irq)
struct irq_desc *desc; struct irq_desc *desc;
unsigned long flags; unsigned long flags;
if (irq >= NR_IRQS) { if (irq >= nr_irqs) {
WARN(1, KERN_ERR "Trying to initialize invalid IRQ%d\n", irq); WARN(1, KERN_ERR "Trying to initialize invalid IRQ%d\n", irq);
return; return;
} }
@ -60,7 +60,7 @@ void dynamic_irq_cleanup(unsigned int irq)
struct irq_desc *desc; struct irq_desc *desc;
unsigned long flags; unsigned long flags;
if (irq >= NR_IRQS) { if (irq >= nr_irqs) {
WARN(1, KERN_ERR "Trying to cleanup invalid IRQ%d\n", irq); WARN(1, KERN_ERR "Trying to cleanup invalid IRQ%d\n", irq);
return; return;
} }
@ -92,7 +92,7 @@ int set_irq_chip(unsigned int irq, struct irq_chip *chip)
struct irq_desc *desc; struct irq_desc *desc;
unsigned long flags; unsigned long flags;
if (irq >= NR_IRQS) { if (irq >= nr_irqs) {
WARN(1, KERN_ERR "Trying to install chip for IRQ%d\n", irq); WARN(1, KERN_ERR "Trying to install chip for IRQ%d\n", irq);
return -EINVAL; return -EINVAL;
} }
@ -121,7 +121,7 @@ int set_irq_type(unsigned int irq, unsigned int type)
unsigned long flags; unsigned long flags;
int ret = -ENXIO; int ret = -ENXIO;
if (irq >= NR_IRQS) { if (irq >= nr_irqs) {
printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq); printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq);
return -ENODEV; return -ENODEV;
} }
@ -149,7 +149,7 @@ int set_irq_data(unsigned int irq, void *data)
struct irq_desc *desc; struct irq_desc *desc;
unsigned long flags; unsigned long flags;
if (irq >= NR_IRQS) { if (irq >= nr_irqs) {
printk(KERN_ERR printk(KERN_ERR
"Trying to install controller data for IRQ%d\n", irq); "Trying to install controller data for IRQ%d\n", irq);
return -EINVAL; return -EINVAL;
@ -175,7 +175,7 @@ int set_irq_msi(unsigned int irq, struct msi_desc *entry)
struct irq_desc *desc; struct irq_desc *desc;
unsigned long flags; unsigned long flags;
if (irq >= NR_IRQS) { if (irq >= nr_irqs) {
printk(KERN_ERR printk(KERN_ERR
"Trying to install msi data for IRQ%d\n", irq); "Trying to install msi data for IRQ%d\n", irq);
return -EINVAL; return -EINVAL;
@ -201,7 +201,7 @@ int set_irq_chip_data(unsigned int irq, void *data)
struct irq_desc *desc = irq_desc + irq; struct irq_desc *desc = irq_desc + irq;
unsigned long flags; unsigned long flags;
if (irq >= NR_IRQS || !desc->chip) { if (irq >= nr_irqs || !desc->chip) {
printk(KERN_ERR "BUG: bad set_irq_chip_data(IRQ#%d)\n", irq); printk(KERN_ERR "BUG: bad set_irq_chip_data(IRQ#%d)\n", irq);
return -EINVAL; return -EINVAL;
} }
@ -545,7 +545,7 @@ __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
struct irq_desc *desc; struct irq_desc *desc;
unsigned long flags; unsigned long flags;
if (irq >= NR_IRQS) { if (irq >= nr_irqs) {
printk(KERN_ERR printk(KERN_ERR
"Trying to install type control for IRQ%d\n", irq); "Trying to install type control for IRQ%d\n", irq);
return; return;
@ -610,7 +610,7 @@ void __init set_irq_noprobe(unsigned int irq)
struct irq_desc *desc; struct irq_desc *desc;
unsigned long flags; unsigned long flags;
if (irq >= NR_IRQS) { if (irq >= nr_irqs) {
printk(KERN_ERR "Trying to mark IRQ%d non-probeable\n", irq); printk(KERN_ERR "Trying to mark IRQ%d non-probeable\n", irq);
return; return;
@ -628,7 +628,7 @@ void __init set_irq_probe(unsigned int irq)
struct irq_desc *desc; struct irq_desc *desc;
unsigned long flags; unsigned long flags;
if (irq >= NR_IRQS) { if (irq >= nr_irqs) {
printk(KERN_ERR "Trying to mark IRQ%d probeable\n", irq); printk(KERN_ERR "Trying to mark IRQ%d probeable\n", irq);
return; return;

View File

@ -47,6 +47,7 @@ handle_bad_irq(unsigned int irq, struct irq_desc *desc)
* *
* Controller mappings for all interrupt sources: * Controller mappings for all interrupt sources:
*/ */
int nr_irqs = NR_IRQS;
struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = { struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
[0 ... NR_IRQS-1] = { [0 ... NR_IRQS-1] = {
.status = IRQ_DISABLED, .status = IRQ_DISABLED,
@ -265,7 +266,7 @@ void early_init_irq_lock_class(void)
{ {
int i; int i;
for (i = 0; i < NR_IRQS; i++) for (i = 0; i < nr_irqs; i++)
lockdep_set_class(&irq_desc[i].lock, &irq_desc_lock_class); lockdep_set_class(&irq_desc[i].lock, &irq_desc_lock_class);
} }

View File

@ -34,7 +34,7 @@ void synchronize_irq(unsigned int irq)
struct irq_desc *desc = irq_desc + irq; struct irq_desc *desc = irq_desc + irq;
unsigned int status; unsigned int status;
if (irq >= NR_IRQS) if (irq >= nr_irqs)
return; return;
do { do {
@ -143,7 +143,7 @@ void disable_irq_nosync(unsigned int irq)
struct irq_desc *desc = irq_desc + irq; struct irq_desc *desc = irq_desc + irq;
unsigned long flags; unsigned long flags;
if (irq >= NR_IRQS) if (irq >= nr_irqs)
return; return;
spin_lock_irqsave(&desc->lock, flags); spin_lock_irqsave(&desc->lock, flags);
@ -171,7 +171,7 @@ void disable_irq(unsigned int irq)
{ {
struct irq_desc *desc = irq_desc + irq; struct irq_desc *desc = irq_desc + irq;
if (irq >= NR_IRQS) if (irq >= nr_irqs)
return; return;
disable_irq_nosync(irq); disable_irq_nosync(irq);
@ -214,7 +214,7 @@ void enable_irq(unsigned int irq)
struct irq_desc *desc = irq_desc + irq; struct irq_desc *desc = irq_desc + irq;
unsigned long flags; unsigned long flags;
if (irq >= NR_IRQS) if (irq >= nr_irqs)
return; return;
spin_lock_irqsave(&desc->lock, flags); spin_lock_irqsave(&desc->lock, flags);
@ -290,7 +290,7 @@ int can_request_irq(unsigned int irq, unsigned long irqflags)
{ {
struct irqaction *action; struct irqaction *action;
if (irq >= NR_IRQS || irq_desc[irq].status & IRQ_NOREQUEST) if (irq >= nr_irqs || irq_desc[irq].status & IRQ_NOREQUEST)
return 0; return 0;
action = irq_desc[irq].action; action = irq_desc[irq].action;
@ -356,7 +356,7 @@ int setup_irq(unsigned int irq, struct irqaction *new)
int shared = 0; int shared = 0;
int ret; int ret;
if (irq >= NR_IRQS) if (irq >= nr_irqs)
return -EINVAL; return -EINVAL;
if (desc->chip == &no_irq_chip) if (desc->chip == &no_irq_chip)
@ -515,7 +515,7 @@ void free_irq(unsigned int irq, void *dev_id)
unsigned long flags; unsigned long flags;
WARN_ON(in_interrupt()); WARN_ON(in_interrupt());
if (irq >= NR_IRQS) if (irq >= nr_irqs)
return; return;
desc = irq_desc + irq; desc = irq_desc + irq;
@ -630,7 +630,7 @@ int request_irq(unsigned int irq, irq_handler_t handler,
*/ */
if ((irqflags & IRQF_SHARED) && !dev_id) if ((irqflags & IRQF_SHARED) && !dev_id)
return -EINVAL; return -EINVAL;
if (irq >= NR_IRQS) if (irq >= nr_irqs)
return -EINVAL; return -EINVAL;
if (irq_desc[irq].status & IRQ_NOREQUEST) if (irq_desc[irq].status & IRQ_NOREQUEST)
return -EINVAL; return -EINVAL;

View File

@ -240,7 +240,7 @@ void init_irq_proc(void)
/* /*
* Create entries for all existing IRQs. * Create entries for all existing IRQs.
*/ */
for (i = 0; i < NR_IRQS; i++) for (i = 0; i < nr_irqs; i++)
register_irq_proc(i); register_irq_proc(i);
} }

View File

@ -33,8 +33,8 @@ static void resend_irqs(unsigned long arg)
struct irq_desc *desc; struct irq_desc *desc;
int irq; int irq;
while (!bitmap_empty(irqs_resend, NR_IRQS)) { while (!bitmap_empty(irqs_resend, nr_irqs)) {
irq = find_first_bit(irqs_resend, NR_IRQS); irq = find_first_bit(irqs_resend, nr_irqs);
clear_bit(irq, irqs_resend); clear_bit(irq, irqs_resend);
desc = irq_desc + irq; desc = irq_desc + irq;
local_irq_disable(); local_irq_disable();

View File

@ -91,7 +91,7 @@ static int misrouted_irq(int irq)
int i; int i;
int ok = 0; int ok = 0;
for (i = 1; i < NR_IRQS; i++) { for (i = 1; i < nr_irqs; i++) {
struct irq_desc *desc = irq_desc + i; struct irq_desc *desc = irq_desc + i;
if (i == irq) /* Already tried */ if (i == irq) /* Already tried */
@ -107,7 +107,7 @@ static int misrouted_irq(int irq)
static void poll_spurious_irqs(unsigned long dummy) static void poll_spurious_irqs(unsigned long dummy)
{ {
int i; int i;
for (i = 1; i < NR_IRQS; i++) { for (i = 1; i < nr_irqs; i++) {
struct irq_desc *desc = irq_desc + i; struct irq_desc *desc = irq_desc + i;
unsigned int status; unsigned int status;