]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/irq/manage.c
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[linux-2.6-omap-h63xx.git] / kernel / irq / manage.c
index fcce5181e45314280ed2fce833f8a20a507bc7b7..8b961adc3bd2d8f27cc14b2b0701e93522e2c232 100644 (file)
@@ -137,16 +137,40 @@ EXPORT_SYMBOL(enable_irq);
  *     @irq:   interrupt to control
  *     @on:    enable/disable power management wakeup
  *
- *     Enable/disable power management wakeup mode
+ *     Enable/disable power management wakeup mode, which is
+ *     disabled by default.  Enables and disables must match,
+ *     just as they match for non-wakeup mode support.
+ *
+ *     Wakeup mode lets this IRQ wake the system from sleep
+ *     states like "suspend to RAM".
  */
 int set_irq_wake(unsigned int irq, unsigned int on)
 {
        struct irq_desc *desc = irq_desc + irq;
        unsigned long flags;
        int ret = -ENXIO;
+       int (*set_wake)(unsigned, unsigned) = desc->chip->set_wake;
 
+       /* wakeup-capable irqs can be shared between drivers that
+        * don't need to have the same sleep mode behaviors.
+        */
        spin_lock_irqsave(&desc->lock, flags);
-       if (desc->chip->set_wake)
+       if (on) {
+               if (desc->wake_depth++ == 0)
+                       desc->status |= IRQ_WAKEUP;
+               else
+                       set_wake = NULL;
+       } else {
+               if (desc->wake_depth == 0) {
+                       printk(KERN_WARNING "Unbalanced IRQ %d "
+                                       "wake disable\n", irq);
+                       WARN_ON(1);
+               } else if (--desc->wake_depth == 0)
+                       desc->status &= ~IRQ_WAKEUP;
+               else
+                       set_wake = NULL;
+       }
+       if (set_wake)
                ret = desc->chip->set_wake(irq, on);
        spin_unlock_irqrestore(&desc->lock, flags);
        return ret;
@@ -167,7 +191,7 @@ int can_request_irq(unsigned int irq, unsigned long irqflags)
 
        action = irq_desc[irq].action;
        if (action)
-               if (irqflags & action->flags & SA_SHIRQ)
+               if (irqflags & action->flags & IRQF_SHARED)
                        action = NULL;
 
        return !action;
@@ -192,6 +216,7 @@ int setup_irq(unsigned int irq, struct irqaction *new)
 {
        struct irq_desc *desc = irq_desc + irq;
        struct irqaction *old, **p;
+       const char *old_name = NULL;
        unsigned long flags;
        int shared = 0;
 
@@ -205,7 +230,7 @@ int setup_irq(unsigned int irq, struct irqaction *new)
         * so we have to be careful not to interfere with a
         * running system.
         */
-       if (new->flags & SA_SAMPLE_RANDOM) {
+       if (new->flags & IRQF_SAMPLE_RANDOM) {
                /*
                 * This function might sleep, we want to call it first,
                 * outside of the atomic block.
@@ -227,17 +252,19 @@ int setup_irq(unsigned int irq, struct irqaction *new)
                /*
                 * Can't share interrupts unless both agree to and are
                 * the same type (level, edge, polarity). So both flag
-                * fields must have SA_SHIRQ set and the bits which
+                * fields must have IRQF_SHARED set and the bits which
                 * set the trigger type must match.
                 */
-               if (!((old->flags & new->flags) & SA_SHIRQ) ||
-                   ((old->flags ^ new->flags) & SA_TRIGGER_MASK))
+               if (!((old->flags & new->flags) & IRQF_SHARED) ||
+                   ((old->flags ^ new->flags) & IRQF_TRIGGER_MASK)) {
+                       old_name = old->name;
                        goto mismatch;
+               }
 
-#if defined(CONFIG_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
+#if defined(CONFIG_IRQ_PER_CPU)
                /* All handlers must agree on per-cpuness */
-               if ((old->flags & SA_PERCPU_IRQ) !=
-                   (new->flags & SA_PERCPU_IRQ))
+               if ((old->flags & IRQF_PERCPU) !=
+                   (new->flags & IRQF_PERCPU))
                        goto mismatch;
 #endif
 
@@ -250,24 +277,24 @@ int setup_irq(unsigned int irq, struct irqaction *new)
        }
 
        *p = new;
-#if defined(CONFIG_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
-       if (new->flags & SA_PERCPU_IRQ)
+#if defined(CONFIG_IRQ_PER_CPU)
+       if (new->flags & IRQF_PERCPU)
                desc->status |= IRQ_PER_CPU;
 #endif
        if (!shared) {
                irq_chip_set_defaults(desc->chip);
 
                /* Setup the type (level, edge polarity) if configured: */
-               if (new->flags & SA_TRIGGER_MASK) {
+               if (new->flags & IRQF_TRIGGER_MASK) {
                        if (desc->chip && desc->chip->set_type)
                                desc->chip->set_type(irq,
-                                               new->flags & SA_TRIGGER_MASK);
+                                               new->flags & IRQF_TRIGGER_MASK);
                        else
                                /*
-                                * SA_TRIGGER_* but the PIC does not support
+                                * IRQF_TRIGGER_* but the PIC does not support
                                 * multiple flow-types?
                                 */
-                               printk(KERN_WARNING "No SA_TRIGGER set_type "
+                               printk(KERN_WARNING "No IRQF_TRIGGER set_type "
                                       "function for IRQ %d (%s)\n", irq,
                                       desc->chip ? desc->chip->name :
                                       "unknown");
@@ -288,6 +315,9 @@ int setup_irq(unsigned int irq, struct irqaction *new)
                        /* Undo nested disables: */
                        desc->depth = 1;
        }
+       /* Reset broken irq detection when installing new handler */
+       desc->irq_count = 0;
+       desc->irqs_unhandled = 0;
        spin_unlock_irqrestore(&desc->lock, flags);
 
        new->irq = irq;
@@ -298,11 +328,13 @@ int setup_irq(unsigned int irq, struct irqaction *new)
        return 0;
 
 mismatch:
-       spin_unlock_irqrestore(&desc->lock, flags);
-       if (!(new->flags & SA_PROBEIRQ)) {
+       if (!(new->flags & IRQF_PROBE_SHARED)) {
                printk(KERN_ERR "IRQ handler type mismatch for IRQ %d\n", irq);
+               if (old_name)
+                       printk(KERN_ERR "current handler: %s\n", old_name);
                dump_stack();
        }
+       spin_unlock_irqrestore(&desc->lock, flags);
        return -EBUSY;
 }
 
@@ -398,25 +430,30 @@ EXPORT_SYMBOL(free_irq);
  *
  *     Flags:
  *
- *     SA_SHIRQ                Interrupt is shared
- *     SA_INTERRUPT            Disable local interrupts while processing
- *     SA_SAMPLE_RANDOM        The interrupt can be used for entropy
+ *     IRQF_SHARED             Interrupt is shared
+ *     IRQF_DISABLED   Disable local interrupts while processing
+ *     IRQF_SAMPLE_RANDOM      The interrupt can be used for entropy
  *
  */
-int request_irq(unsigned int irq,
-               irqreturn_t (*handler)(int, void *, struct pt_regs *),
+int request_irq(unsigned int irq, irq_handler_t handler,
                unsigned long irqflags, const char *devname, void *dev_id)
 {
        struct irqaction *action;
        int retval;
 
+#ifdef CONFIG_LOCKDEP
+       /*
+        * Lockdep wants atomic interrupt handlers:
+        */
+       irqflags |= SA_INTERRUPT;
+#endif
        /*
         * Sanity-check: shared interrupts must pass in a real dev-ID,
         * otherwise we'll have trouble later trying to figure out
         * which interrupt is which (messes up the interrupt freeing
         * logic etc).
         */
-       if ((irqflags & SA_SHIRQ) && !dev_id)
+       if ((irqflags & IRQF_SHARED) && !dev_id)
                return -EINVAL;
        if (irq >= NR_IRQS)
                return -EINVAL;
@@ -445,4 +482,3 @@ int request_irq(unsigned int irq,
        return retval;
 }
 EXPORT_SYMBOL(request_irq);
-