]> git.karo-electronics.de Git - linux-beck.git/commitdiff
genirq: Implement irq_get/put_desc_[bus]locked/unlock()
authorThomas Gleixner <tglx@linutronix.de>
Sat, 12 Feb 2011 11:16:16 +0000 (12:16 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Sat, 19 Feb 2011 11:58:23 +0000 (12:58 +0100)
Most of the managing functions get the irq descriptor and lock it -
either with or without buslock. Instead of open coding this over and
over provide a common function to do that.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
kernel/irq/internals.h
kernel/irq/irqdesc.c

index f80a77471617716bdefe59c3f19d04ad2caf2847..935bec4bfa874841813cfc3fcabbd2efa6e2810b 100644 (file)
@@ -126,6 +126,34 @@ static inline void chip_bus_sync_unlock(struct irq_desc *desc)
                desc->irq_data.chip->irq_bus_sync_unlock(&desc->irq_data);
 }
 
+struct irq_desc *
+__irq_get_desc_lock(unsigned int irq, unsigned long *flags, bool bus);
+void __irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags, bool bus);
+
+static inline struct irq_desc *
+irq_get_desc_buslock(unsigned int irq, unsigned long *flags)
+{
+       return __irq_get_desc_lock(irq, flags, true);
+}
+
+static inline void
+irq_put_desc_busunlock(struct irq_desc *desc, unsigned long flags)
+{
+       __irq_put_desc_unlock(desc, flags, true);
+}
+
+static inline struct irq_desc *
+irq_get_desc_lock(unsigned int irq, unsigned long *flags)
+{
+       return __irq_get_desc_lock(irq, flags, false);
+}
+
+static inline void
+irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags)
+{
+       __irq_put_desc_unlock(desc, flags, false);
+}
+
 /*
  * Manipulation functions for irq_data.state
  */
index 3387fbd7f2f425c26ba8f5f8028ce1fd7e3d014b..394ab6a6c62cc2fe9df817e6acd8c087c5f9ff38 100644 (file)
@@ -402,6 +402,26 @@ unsigned int irq_get_next_irq(unsigned int offset)
        return find_next_bit(allocated_irqs, nr_irqs, offset);
 }
 
+struct irq_desc *
+__irq_get_desc_lock(unsigned int irq, unsigned long *flags, bool bus)
+{
+       struct irq_desc *desc = irq_to_desc(irq);
+
+       if (desc) {
+               if (bus)
+                       chip_bus_lock(desc);
+               raw_spin_lock_irqsave(&desc->lock, *flags);
+       }
+       return desc;
+}
+
+void __irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags, bool bus)
+{
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
+       if (bus)
+               chip_bus_sync_unlock(desc);
+}
+
 /**
  * dynamic_irq_cleanup - cleanup a dynamically allocated irq
  * @irq:       irq number to initialize