Skip to content

Commit d5eb4ad

Browse files
committed
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>
1 parent 091738a commit d5eb4ad

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

‎kernel/irq/internals.h‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,34 @@ static inline void chip_bus_sync_unlock(struct irq_desc *desc)
126126
desc->irq_data.chip->irq_bus_sync_unlock(&desc->irq_data);
127127
}
128128

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+
129157
/*
130158
* Manipulation functions for irq_data.state
131159
*/

‎kernel/irq/irqdesc.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,26 @@ unsigned int irq_get_next_irq(unsigned int offset)
402402
return find_next_bit(allocated_irqs, nr_irqs, offset);
403403
}
404404

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+
405425
/**
406426
* dynamic_irq_cleanup - cleanup a dynamically allocated irq
407427
* @irq: irq number to initialize

0 commit comments

Comments
 (0)