]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/irq/chip.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
[linux-2.6-omap-h63xx.git] / kernel / irq / chip.c
index 4ef555c50db8da27f02106e1ca50e656ad47e6bb..10b5092e9bfe749da57b2ab408e3f6d38ae81d75 100644 (file)
  */
 void dynamic_irq_init(unsigned int irq)
 {
-       struct irq_desc *desc;
+       struct irq_desc *desc = irq_to_desc(irq);
        unsigned long flags;
 
-       /* first time to use this irq_desc */
-       desc = irq_to_desc_alloc(irq);
        if (!desc) {
                WARN(1, KERN_ERR "Trying to initialize invalid IRQ%d\n", irq);
                return;
@@ -58,10 +56,9 @@ void dynamic_irq_init(unsigned int irq)
  */
 void dynamic_irq_cleanup(unsigned int irq)
 {
-       struct irq_desc *desc;
+       struct irq_desc *desc = irq_to_desc(irq);
        unsigned long flags;
 
-       desc = irq_to_desc(irq);
        if (!desc) {
                WARN(1, KERN_ERR "Trying to cleanup invalid IRQ%d\n", irq);
                return;
@@ -79,6 +76,7 @@ void dynamic_irq_cleanup(unsigned int irq)
        desc->chip_data = NULL;
        desc->handle_irq = handle_bad_irq;
        desc->chip = &no_irq_chip;
+       desc->name = NULL;
        spin_unlock_irqrestore(&desc->lock, flags);
 }
 
@@ -90,10 +88,9 @@ void dynamic_irq_cleanup(unsigned int irq)
  */
 int set_irq_chip(unsigned int irq, struct irq_chip *chip)
 {
-       struct irq_desc *desc;
+       struct irq_desc *desc = irq_to_desc(irq);
        unsigned long flags;
 
-       desc = irq_to_desc(irq);
        if (!desc) {
                WARN(1, KERN_ERR "Trying to install chip for IRQ%d\n", irq);
                return -EINVAL;
@@ -102,7 +99,6 @@ int set_irq_chip(unsigned int irq, struct irq_chip *chip)
        if (!chip)
                chip = &no_irq_chip;
 
-       desc = irq_to_desc(irq);
        spin_lock_irqsave(&desc->lock, flags);
        irq_chip_set_defaults(chip);
        desc->chip = chip;
@@ -119,11 +115,10 @@ EXPORT_SYMBOL(set_irq_chip);
  */
 int set_irq_type(unsigned int irq, unsigned int type)
 {
-       struct irq_desc *desc;
+       struct irq_desc *desc = irq_to_desc(irq);
        unsigned long flags;
        int ret = -ENXIO;
 
-       desc = irq_to_desc(irq);
        if (!desc) {
                printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq);
                return -ENODEV;
@@ -133,7 +128,7 @@ int set_irq_type(unsigned int irq, unsigned int type)
                return 0;
 
        spin_lock_irqsave(&desc->lock, flags);
-       ret = __irq_set_trigger(desc, irq, flags);
+       ret = __irq_set_trigger(desc, irq, type);
        spin_unlock_irqrestore(&desc->lock, flags);
        return ret;
 }
@@ -148,10 +143,9 @@ EXPORT_SYMBOL(set_irq_type);
  */
 int set_irq_data(unsigned int irq, void *data)
 {
-       struct irq_desc *desc;
+       struct irq_desc *desc = irq_to_desc(irq);
        unsigned long flags;
 
-       desc = irq_to_desc(irq);
        if (!desc) {
                printk(KERN_ERR
                       "Trying to install controller data for IRQ%d\n", irq);
@@ -174,10 +168,9 @@ EXPORT_SYMBOL(set_irq_data);
  */
 int set_irq_msi(unsigned int irq, struct msi_desc *entry)
 {
-       struct irq_desc *desc;
+       struct irq_desc *desc = irq_to_desc(irq);
        unsigned long flags;
 
-       desc = irq_to_desc(irq);
        if (!desc) {
                printk(KERN_ERR
                       "Trying to install msi data for IRQ%d\n", irq);
@@ -201,10 +194,9 @@ int set_irq_msi(unsigned int irq, struct msi_desc *entry)
  */
 int set_irq_chip_data(unsigned int irq, void *data)
 {
-       struct irq_desc *desc;
+       struct irq_desc *desc = irq_to_desc(irq);
        unsigned long flags;
 
-       desc = irq_to_desc(irq);
        if (!desc) {
                printk(KERN_ERR
                       "Trying to install chip data for IRQ%d\n", irq);
@@ -229,9 +221,8 @@ EXPORT_SYMBOL(set_irq_chip_data);
  */
 static void default_enable(unsigned int irq)
 {
-       struct irq_desc *desc;
+       struct irq_desc *desc = irq_to_desc(irq);
 
-       desc = irq_to_desc(irq);
        desc->chip->unmask(irq);
        desc->status &= ~IRQ_MASKED;
 }
@@ -248,11 +239,9 @@ static void default_disable(unsigned int irq)
  */
 static unsigned int default_startup(unsigned int irq)
 {
-       struct irq_desc *desc;
+       struct irq_desc *desc = irq_to_desc(irq);
 
-       desc = irq_to_desc(irq);
        desc->chip->enable(irq);
-
        return 0;
 }
 
@@ -261,9 +250,8 @@ static unsigned int default_startup(unsigned int irq)
  */
 static void default_shutdown(unsigned int irq)
 {
-       struct irq_desc *desc;
+       struct irq_desc *desc = irq_to_desc(irq);
 
-       desc = irq_to_desc(irq);
        desc->chip->mask(irq);
        desc->status |= IRQ_MASKED;
 }
@@ -327,11 +315,7 @@ handle_simple_irq(unsigned int irq, struct irq_desc *desc)
        if (unlikely(desc->status & IRQ_INPROGRESS))
                goto out_unlock;
        desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
-#ifdef CONFIG_HAVE_DYN_ARRAY
-       kstat_irqs_this_cpu(desc)++;
-#else
-       kstat_irqs_this_cpu(irq)++;
-#endif
+       kstat_incr_irqs_this_cpu(irq, desc);
 
        action = desc->action;
        if (unlikely(!action || (desc->status & IRQ_DISABLED)))
@@ -372,11 +356,7 @@ handle_level_irq(unsigned int irq, struct irq_desc *desc)
        if (unlikely(desc->status & IRQ_INPROGRESS))
                goto out_unlock;
        desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
-#ifdef CONFIG_HAVE_DYN_ARRAY
-       kstat_irqs_this_cpu(desc)++;
-#else
-       kstat_irqs_this_cpu(irq)++;
-#endif
+       kstat_incr_irqs_this_cpu(irq, desc);
 
        /*
         * If its disabled or no action available
@@ -423,11 +403,7 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
                goto out;
 
        desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
-#ifdef CONFIG_HAVE_DYN_ARRAY
-       kstat_irqs_this_cpu(desc)++;
-#else
-       kstat_irqs_this_cpu(irq)++;
-#endif
+       kstat_incr_irqs_this_cpu(irq, desc);
 
        /*
         * If its disabled or no action available
@@ -491,11 +467,7 @@ handle_edge_irq(unsigned int irq, struct irq_desc *desc)
                mask_ack_irq(desc, irq);
                goto out_unlock;
        }
-#ifdef CONFIG_HAVE_DYN_ARRAY
-       kstat_irqs_this_cpu(desc)++;
-#else
-       kstat_irqs_this_cpu(irq)++;
-#endif
+       kstat_incr_irqs_this_cpu(irq, desc);
 
        /* Start handling the irq */
        desc->chip->ack(irq);
@@ -550,11 +522,7 @@ handle_percpu_irq(unsigned int irq, struct irq_desc *desc)
 {
        irqreturn_t action_ret;
 
-#ifdef CONFIG_HAVE_DYN_ARRAY
-       kstat_irqs_this_cpu(desc)++;
-#else
-       kstat_irqs_this_cpu(irq)++;
-#endif
+       kstat_incr_irqs_this_cpu(irq, desc);
 
        if (desc->chip->ack)
                desc->chip->ack(irq);
@@ -571,10 +539,9 @@ void
 __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
                  const char *name)
 {
-       struct irq_desc *desc;
+       struct irq_desc *desc = irq_to_desc(irq);
        unsigned long flags;
 
-       desc = irq_to_desc(irq);
        if (!desc) {
                printk(KERN_ERR
                       "Trying to install type control for IRQ%d\n", irq);
@@ -635,13 +602,11 @@ set_irq_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
 
 void __init set_irq_noprobe(unsigned int irq)
 {
-       struct irq_desc *desc;
+       struct irq_desc *desc = irq_to_desc(irq);
        unsigned long flags;
 
-       desc = irq_to_desc(irq);
        if (!desc) {
                printk(KERN_ERR "Trying to mark IRQ%d non-probeable\n", irq);
-
                return;
        }
 
@@ -652,13 +617,11 @@ void __init set_irq_noprobe(unsigned int irq)
 
 void __init set_irq_probe(unsigned int irq)
 {
-       struct irq_desc *desc;
+       struct irq_desc *desc = irq_to_desc(irq);
        unsigned long flags;
 
-       desc = irq_to_desc(irq);
        if (!desc) {
                printk(KERN_ERR "Trying to mark IRQ%d probeable\n", irq);
-
                return;
        }