diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2011-02-12 06:16:16 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2011-02-19 06:58:23 -0500 |
commit | d5eb4ad2dfb2dfae43fd51bc8630b4fc3ef00e92 (patch) | |
tree | ec164ed62dd55d14e0f73e1ba6f894433f70394e /kernel/irq | |
parent | 091738a266fc74329ae186f22ff2b3f01319112d (diff) |
genirq: Implement irq_get/put_desc_[bus]locked/unlock()
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>
Diffstat (limited to 'kernel/irq')
-rw-r--r-- | kernel/irq/internals.h | 28 | ||||
-rw-r--r-- | kernel/irq/irqdesc.c | 20 |
2 files changed, 48 insertions, 0 deletions
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h index f80a77471617..935bec4bfa87 100644 --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h | |||
@@ -126,6 +126,34 @@ static inline void chip_bus_sync_unlock(struct irq_desc *desc) | |||
126 | desc->irq_data.chip->irq_bus_sync_unlock(&desc->irq_data); | 126 | desc->irq_data.chip->irq_bus_sync_unlock(&desc->irq_data); |
127 | } | 127 | } |
128 | 128 | ||
129 | struct irq_desc * | ||
130 | __irq_get_desc_lock(unsigned int irq, unsigned long *flags, bool bus); | ||
131 | void __irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags, bool bus); | ||
132 | |||
133 | static inline struct irq_desc * | ||
134 | irq_get_desc_buslock(unsigned int irq, unsigned long *flags) | ||
135 | { | ||
136 | return __irq_get_desc_lock(irq, flags, true); | ||
137 | } | ||
138 | |||
139 | static inline void | ||
140 | irq_put_desc_busunlock(struct irq_desc *desc, unsigned long flags) | ||
141 | { | ||
142 | __irq_put_desc_unlock(desc, flags, true); | ||
143 | } | ||
144 | |||
145 | static inline struct irq_desc * | ||
146 | irq_get_desc_lock(unsigned int irq, unsigned long *flags) | ||
147 | { | ||
148 | return __irq_get_desc_lock(irq, flags, false); | ||
149 | } | ||
150 | |||
151 | static inline void | ||
152 | irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags) | ||
153 | { | ||
154 | __irq_put_desc_unlock(desc, flags, false); | ||
155 | } | ||
156 | |||
129 | /* | 157 | /* |
130 | * Manipulation functions for irq_data.state | 158 | * Manipulation functions for irq_data.state |
131 | */ | 159 | */ |
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index 3387fbd7f2f4..394ab6a6c62c 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c | |||
@@ -402,6 +402,26 @@ unsigned int irq_get_next_irq(unsigned int offset) | |||
402 | return find_next_bit(allocated_irqs, nr_irqs, offset); | 402 | return find_next_bit(allocated_irqs, nr_irqs, offset); |
403 | } | 403 | } |
404 | 404 | ||
405 | struct irq_desc * | ||
406 | __irq_get_desc_lock(unsigned int irq, unsigned long *flags, bool bus) | ||
407 | { | ||
408 | struct irq_desc *desc = irq_to_desc(irq); | ||
409 | |||
410 | if (desc) { | ||
411 | if (bus) | ||
412 | chip_bus_lock(desc); | ||
413 | raw_spin_lock_irqsave(&desc->lock, *flags); | ||
414 | } | ||
415 | return desc; | ||
416 | } | ||
417 | |||
418 | void __irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags, bool bus) | ||
419 | { | ||
420 | raw_spin_unlock_irqrestore(&desc->lock, flags); | ||
421 | if (bus) | ||
422 | chip_bus_sync_unlock(desc); | ||
423 | } | ||
424 | |||
405 | /** | 425 | /** |
406 | * dynamic_irq_cleanup - cleanup a dynamically allocated irq | 426 | * dynamic_irq_cleanup - cleanup a dynamically allocated irq |
407 | * @irq: irq number to initialize | 427 | * @irq: irq number to initialize |