]> Pileus Git - ~andy/linux/blobdiff - kernel/irq/manage.c
[PATCH] genirq: rename desc->handler to desc->chip
[~andy/linux] / kernel / irq / manage.c
index 81c49a4d679eb03e54b9be8bb70d5f8f98447a41..31ee1f3bfcf92bae6ddab6b240d9623e81b59b28 100644 (file)
@@ -69,7 +69,7 @@ void disable_irq_nosync(unsigned int irq)
        spin_lock_irqsave(&desc->lock, flags);
        if (!desc->depth++) {
                desc->status |= IRQ_DISABLED;
-               desc->handler->disable(irq);
+               desc->chip->disable(irq);
        }
        spin_unlock_irqrestore(&desc->lock, flags);
 }
@@ -131,9 +131,9 @@ void enable_irq(unsigned int irq)
                desc->status = status;
                if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) {
                        desc->status = status | IRQ_REPLAY;
-                       hw_resend_irq(desc->handler,irq);
+                       hw_resend_irq(desc->chip,irq);
                }
-               desc->handler->enable(irq);
+               desc->chip->enable(irq);
                /* fall-through */
        }
        default:
@@ -178,7 +178,7 @@ int setup_irq(unsigned int irq, struct irqaction * new)
        if (irq >= NR_IRQS)
                return -EINVAL;
 
-       if (desc->handler == &no_irq_type)
+       if (desc->chip == &no_irq_type)
                return -ENOSYS;
        /*
         * Some drivers like serial.c use request_irq() heavily,
@@ -204,10 +204,14 @@ int setup_irq(unsigned int irq, struct irqaction * new)
        p = &desc->action;
        if ((old = *p) != NULL) {
                /* Can't share interrupts unless both agree to */
-               if (!(old->flags & new->flags & SA_SHIRQ)) {
-                       spin_unlock_irqrestore(&desc->lock,flags);
-                       return -EBUSY;
-               }
+               if (!(old->flags & new->flags & SA_SHIRQ))
+                       goto mismatch;
+
+#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
+               /* All handlers must agree on per-cpuness */
+               if ((old->flags & IRQ_PER_CPU) != (new->flags & IRQ_PER_CPU))
+                       goto mismatch;
+#endif
 
                /* add new interrupt at end of irq queue */
                do {
@@ -218,15 +222,18 @@ int setup_irq(unsigned int irq, struct irqaction * new)
        }
 
        *p = new;
-
+#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
+       if (new->flags & SA_PERCPU_IRQ)
+               desc->status |= IRQ_PER_CPU;
+#endif
        if (!shared) {
                desc->depth = 0;
                desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT |
                                  IRQ_WAITING | IRQ_INPROGRESS);
-               if (desc->handler->startup)
-                       desc->handler->startup(irq);
+               if (desc->chip->startup)
+                       desc->chip->startup(irq);
                else
-                       desc->handler->enable(irq);
+                       desc->chip->enable(irq);
        }
        spin_unlock_irqrestore(&desc->lock,flags);
 
@@ -236,6 +243,14 @@ int setup_irq(unsigned int irq, struct irqaction * new)
        register_handler_proc(irq, new);
 
        return 0;
+
+mismatch:
+       spin_unlock_irqrestore(&desc->lock, flags);
+       if (!(new->flags & SA_PROBEIRQ)) {
+               printk(KERN_ERR "%s: irq handler mismatch\n", __FUNCTION__);
+               dump_stack();
+       }
+       return -EBUSY;
 }
 
 /**
@@ -258,6 +273,7 @@ void free_irq(unsigned int irq, void *dev_id)
        struct irqaction **p;
        unsigned long flags;
 
+       WARN_ON(in_interrupt());
        if (irq >= NR_IRQS)
                return;
 
@@ -279,16 +295,16 @@ void free_irq(unsigned int irq, void *dev_id)
 
                        /* Currently used only by UML, might disappear one day.*/
 #ifdef CONFIG_IRQ_RELEASE_METHOD
-                       if (desc->handler->release)
-                               desc->handler->release(irq, dev_id);
+                       if (desc->chip->release)
+                               desc->chip->release(irq, dev_id);
 #endif
 
                        if (!desc->action) {
                                desc->status |= IRQ_DISABLED;
-                               if (desc->handler->shutdown)
-                                       desc->handler->shutdown(irq);
+                               if (desc->chip->shutdown)
+                                       desc->chip->shutdown(irq);
                                else
-                                       desc->handler->disable(irq);
+                                       desc->chip->disable(irq);
                        }
                        spin_unlock_irqrestore(&desc->lock,flags);
                        unregister_handler_proc(irq, action);
@@ -366,6 +382,8 @@ int request_irq(unsigned int irq,
        action->next = NULL;
        action->dev_id = dev_id;
 
+       select_smp_affinity(irq);
+
        retval = setup_irq(irq, action);
        if (retval)
                kfree(action);