]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/irq/chip.c
[PATCH] genirq: do not mask interrupts by default
[linux-2.6-omap-h63xx.git] / kernel / irq / chip.c
index 736cb0bd498f8ff5c7a50d8b60e3130da43d9d7f..76a9106a0bf4ad2a7a7d5805e1fc00c94522b696 100644 (file)
 
 #include "internals.h"
 
+/**
+ *     dynamic_irq_init - initialize a dynamically allocated irq
+ *     @irq:   irq number to initialize
+ */
+void dynamic_irq_init(unsigned int irq)
+{
+       struct irq_desc *desc;
+       unsigned long flags;
+
+       if (irq >= NR_IRQS) {
+               printk(KERN_ERR "Trying to initialize invalid IRQ%d\n", irq);
+               WARN_ON(1);
+               return;
+       }
+
+       /* Ensure we don't have left over values from a previous use of this irq */
+       desc = irq_desc + irq;
+       spin_lock_irqsave(&desc->lock, flags);
+       desc->status = IRQ_DISABLED;
+       desc->chip = &no_irq_chip;
+       desc->handle_irq = handle_bad_irq;
+       desc->depth = 1;
+       desc->msi_desc = NULL;
+       desc->handler_data = NULL;
+       desc->chip_data = NULL;
+       desc->action = NULL;
+       desc->irq_count = 0;
+       desc->irqs_unhandled = 0;
+#ifdef CONFIG_SMP
+       desc->affinity = CPU_MASK_ALL;
+#endif
+       spin_unlock_irqrestore(&desc->lock, flags);
+}
+
+/**
+ *     dynamic_irq_cleanup - cleanup a dynamically allocated irq
+ *     @irq:   irq number to initialize
+ */
+void dynamic_irq_cleanup(unsigned int irq)
+{
+       struct irq_desc *desc;
+       unsigned long flags;
+
+       if (irq >= NR_IRQS) {
+               printk(KERN_ERR "Trying to cleanup invalid IRQ%d\n", irq);
+               WARN_ON(1);
+               return;
+       }
+
+       desc = irq_desc + irq;
+       spin_lock_irqsave(&desc->lock, flags);
+       if (desc->action) {
+               spin_unlock_irqrestore(&desc->lock, flags);
+               printk(KERN_ERR "Destroying IRQ%d without calling free_irq\n",
+                       irq);
+               WARN_ON(1);
+               return;
+       }
+       desc->msi_desc = NULL;
+       desc->handler_data = NULL;
+       desc->chip_data = NULL;
+       desc->handle_irq = handle_bad_irq;
+       desc->chip = &no_irq_chip;
+       spin_unlock_irqrestore(&desc->lock, flags);
+}
+
+
 /**
  *     set_irq_chip - set the irq chip for an irq
  *     @irq:   irq number
@@ -98,6 +165,30 @@ int set_irq_data(unsigned int irq, void *data)
 }
 EXPORT_SYMBOL(set_irq_data);
 
+/**
+ *     set_irq_data - set irq type data for an irq
+ *     @irq:   Interrupt number
+ *     @data:  Pointer to interrupt specific data
+ *
+ *     Set the hardware irq controller data for an irq
+ */
+int set_irq_msi(unsigned int irq, struct msi_desc *entry)
+{
+       struct irq_desc *desc;
+       unsigned long flags;
+
+       if (irq >= NR_IRQS) {
+               printk(KERN_ERR
+                      "Trying to install msi data for IRQ%d\n", irq);
+               return -EINVAL;
+       }
+       desc = irq_desc + irq;
+       spin_lock_irqsave(&desc->lock, flags);
+       desc->msi_desc = entry;
+       spin_unlock_irqrestore(&desc->lock, flags);
+       return 0;
+}
+
 /**
  *     set_irq_chip_data - set irq chip data for an irq
  *     @irq:   Interrupt number
@@ -139,10 +230,6 @@ static void default_enable(unsigned int irq)
  */
 static void default_disable(unsigned int irq)
 {
-       struct irq_desc *desc = irq_desc + irq;
-
-       if (!(desc->status & IRQ_DELAYED_DISABLE))
-               desc->chip->mask(irq);
 }
 
 /*
@@ -170,6 +257,8 @@ void irq_chip_set_defaults(struct irq_chip *chip)
                chip->shutdown = chip->disable;
        if (!chip->name)
                chip->name = chip->typename;
+       if (!chip->end)
+               chip->end = dummy_irq_chip.end;
 }
 
 static inline void mask_ack_irq(struct irq_desc *desc, int irq)
@@ -186,7 +275,6 @@ static inline void mask_ack_irq(struct irq_desc *desc, int irq)
  *     handle_simple_irq - Simple and software-decoded IRQs.
  *     @irq:   the interrupt number
  *     @desc:  the interrupt description structure for this irq
- *     @regs:  pointer to a register structure
  *
  *     Simple interrupts are either sent from a demultiplexing interrupt
  *     handler or come from hardware, where no interrupt hardware control
@@ -196,7 +284,7 @@ static inline void mask_ack_irq(struct irq_desc *desc, int irq)
  *     unmask issues if necessary.
  */
 void fastcall
-handle_simple_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
+handle_simple_irq(unsigned int irq, struct irq_desc *desc)
 {
        struct irqaction *action;
        irqreturn_t action_ret;
@@ -206,19 +294,24 @@ handle_simple_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
 
        if (unlikely(desc->status & IRQ_INPROGRESS))
                goto out_unlock;
-       desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
        kstat_cpu(cpu).irqs[irq]++;
 
        action = desc->action;
-       if (unlikely(!action || (desc->status & IRQ_DISABLED)))
+       if (unlikely(!action || (desc->status & IRQ_DISABLED))) {
+               if (desc->chip->mask)
+                       desc->chip->mask(irq);
+               desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
+               desc->status |= IRQ_PENDING;
                goto out_unlock;
+       }
 
+       desc->status &= ~(IRQ_REPLAY | IRQ_WAITING | IRQ_PENDING);
        desc->status |= IRQ_INPROGRESS;
        spin_unlock(&desc->lock);
 
-       action_ret = handle_IRQ_event(irq, regs, action);
+       action_ret = handle_IRQ_event(irq, action);
        if (!noirqdebug)
-               note_interrupt(irq, desc, action_ret, regs);
+               note_interrupt(irq, desc, action_ret);
 
        spin_lock(&desc->lock);
        desc->status &= ~IRQ_INPROGRESS;
@@ -230,7 +323,6 @@ out_unlock:
  *     handle_level_irq - Level type irq handler
  *     @irq:   the interrupt number
  *     @desc:  the interrupt description structure for this irq
- *     @regs:  pointer to a register structure
  *
  *     Level type interrupts are active as long as the hardware line has
  *     the active level. This may require to mask the interrupt and unmask
@@ -238,7 +330,7 @@ out_unlock:
  *     interrupt line is back to inactive.
  */
 void fastcall
-handle_level_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
+handle_level_irq(unsigned int irq, struct irq_desc *desc)
 {
        unsigned int cpu = smp_processor_id();
        struct irqaction *action;
@@ -266,9 +358,9 @@ handle_level_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
        desc->status &= ~IRQ_PENDING;
        spin_unlock(&desc->lock);
 
-       action_ret = handle_IRQ_event(irq, regs, action);
+       action_ret = handle_IRQ_event(irq, action);
        if (!noirqdebug)
-               note_interrupt(irq, desc, action_ret, regs);
+               note_interrupt(irq, desc, action_ret);
 
        spin_lock(&desc->lock);
        desc->status &= ~IRQ_INPROGRESS;
@@ -282,7 +374,6 @@ out_unlock:
  *     handle_fasteoi_irq - irq handler for transparent controllers
  *     @irq:   the interrupt number
  *     @desc:  the interrupt description structure for this irq
- *     @regs:  pointer to a register structure
  *
  *     Only a single callback will be issued to the chip: an ->eoi()
  *     call when the interrupt has been serviced. This enables support
@@ -290,8 +381,7 @@ out_unlock:
  *     details in hardware, transparently.
  */
 void fastcall
-handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc,
-                  struct pt_regs *regs)
+handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
 {
        unsigned int cpu = smp_processor_id();
        struct irqaction *action;
@@ -307,11 +397,13 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc,
 
        /*
         * If its disabled or no action available
-        * keep it masked and get out of here
+        * then mask it and get out of here:
         */
        action = desc->action;
        if (unlikely(!action || (desc->status & IRQ_DISABLED))) {
                desc->status |= IRQ_PENDING;
+               if (desc->chip->mask)
+                       desc->chip->mask(irq);
                goto out;
        }
 
@@ -319,9 +411,9 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc,
        desc->status &= ~IRQ_PENDING;
        spin_unlock(&desc->lock);
 
-       action_ret = handle_IRQ_event(irq, regs, action);
+       action_ret = handle_IRQ_event(irq, action);
        if (!noirqdebug)
-               note_interrupt(irq, desc, action_ret, regs);
+               note_interrupt(irq, desc, action_ret);
 
        spin_lock(&desc->lock);
        desc->status &= ~IRQ_INPROGRESS;
@@ -335,7 +427,6 @@ out:
  *     handle_edge_irq - edge type IRQ handler
  *     @irq:   the interrupt number
  *     @desc:  the interrupt description structure for this irq
- *     @regs:  pointer to a register structure
  *
  *     Interrupt occures on the falling and/or rising edge of a hardware
  *     signal. The occurence is latched into the irq controller hardware
@@ -349,7 +440,7 @@ out:
  *     loop is left.
  */
 void fastcall
-handle_edge_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
+handle_edge_irq(unsigned int irq, struct irq_desc *desc)
 {
        const unsigned int cpu = smp_processor_id();
 
@@ -400,9 +491,9 @@ handle_edge_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
 
                desc->status &= ~IRQ_PENDING;
                spin_unlock(&desc->lock);
-               action_ret = handle_IRQ_event(irq, regs, action);
+               action_ret = handle_IRQ_event(irq, action);
                if (!noirqdebug)
-                       note_interrupt(irq, desc, action_ret, regs);
+                       note_interrupt(irq, desc, action_ret);
                spin_lock(&desc->lock);
 
        } while ((desc->status & (IRQ_PENDING | IRQ_DISABLED)) == IRQ_PENDING);
@@ -417,12 +508,11 @@ out_unlock:
  *     handle_percpu_IRQ - Per CPU local irq handler
  *     @irq:   the interrupt number
  *     @desc:  the interrupt description structure for this irq
- *     @regs:  pointer to a register structure
  *
  *     Per CPU interrupts on SMP machines without locking requirements
  */
 void fastcall
-handle_percpu_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
+handle_percpu_irq(unsigned int irq, struct irq_desc *desc)
 {
        irqreturn_t action_ret;
 
@@ -431,9 +521,9 @@ handle_percpu_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
        if (desc->chip->ack)
                desc->chip->ack(irq);
 
-       action_ret = handle_IRQ_event(irq, regs, desc->action);
+       action_ret = handle_IRQ_event(irq, desc->action);
        if (!noirqdebug)
-               note_interrupt(irq, desc, action_ret, regs);
+               note_interrupt(irq, desc, action_ret);
 
        if (desc->chip->eoi)
                desc->chip->eoi(irq);
@@ -442,10 +532,8 @@ handle_percpu_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
 #endif /* CONFIG_SMP */
 
 void
-__set_irq_handler(unsigned int irq,
-                 void fastcall (*handle)(unsigned int, irq_desc_t *,
-                                         struct pt_regs *),
-                 int is_chained)
+__set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
+                 const char *name)
 {
        struct irq_desc *desc;
        unsigned long flags;
@@ -460,10 +548,9 @@ __set_irq_handler(unsigned int irq,
 
        if (!handle)
                handle = handle_bad_irq;
-
-       if (desc->chip == &no_irq_chip) {
+       else if (desc->chip == &no_irq_chip) {
                printk(KERN_WARNING "Trying to install %sinterrupt handler "
-                      "for IRQ%d\n", is_chained ? "chained " : " ", irq);
+                      "for IRQ%d\n", is_chained ? "chained " : "", irq);
                /*
                 * Some ARM implementations install a handler for really dumb
                 * interrupt hardware without setting an irq_chip. This worked
@@ -486,6 +573,7 @@ __set_irq_handler(unsigned int irq,
                desc->depth = 1;
        }
        desc->handle_irq = handle;
+       desc->name = name;
 
        if (handle != handle_bad_irq && is_chained) {
                desc->status &= ~IRQ_DISABLED;
@@ -498,36 +586,16 @@ __set_irq_handler(unsigned int irq,
 
 void
 set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip,
-                        void fastcall (*handle)(unsigned int,
-                                                struct irq_desc *,
-                                                struct pt_regs *))
+                        irq_flow_handler_t handle)
 {
        set_irq_chip(irq, chip);
-       __set_irq_handler(irq, handle, 0);
+       __set_irq_handler(irq, handle, 0, NULL);
 }
 
-/*
- * Get a descriptive string for the highlevel handler, for
- * /proc/interrupts output:
- */
-const char *
-handle_irq_name(void fastcall (*handle)(unsigned int, struct irq_desc *,
-                                       struct pt_regs *))
+void
+set_irq_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
+                             irq_flow_handler_t handle, const char *name)
 {
-       if (handle == handle_level_irq)
-               return "level  ";
-       if (handle == handle_fasteoi_irq)
-               return "fasteoi";
-       if (handle == handle_edge_irq)
-               return "edge   ";
-       if (handle == handle_simple_irq)
-               return "simple ";
-#ifdef CONFIG_SMP
-       if (handle == handle_percpu_irq)
-               return "percpu ";
-#endif
-       if (handle == handle_bad_irq)
-               return "bad    ";
-
-       return NULL;
+       set_irq_chip(irq, chip);
+       __set_irq_handler(irq, handle, 0, name);
 }