Skip to content

Commit 46ff4d1

Browse files
committed
genirq/chip: Rework irq_set_chip()
Use the new guards to get and lock the interrupt descriptor and tidy up the code. Fixup the kernel doc comment while at it. No functional change. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent e7c6542 commit 46ff4d1

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

kernel/irq/chip.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,22 @@ struct irqaction chained_action = {
3434
};
3535

3636
/**
37-
* irq_set_chip - set the irq chip for an irq
38-
* @irq: irq number
39-
* @chip: pointer to irq chip description structure
37+
* irq_set_chip - set the irq chip for an irq
38+
* @irq: irq number
39+
* @chip: pointer to irq chip description structure
4040
*/
4141
int irq_set_chip(unsigned int irq, const struct irq_chip *chip)
4242
{
43-
unsigned long flags;
44-
struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
45-
46-
if (!desc)
47-
return -EINVAL;
43+
int ret = -EINVAL;
4844

49-
desc->irq_data.chip = (struct irq_chip *)(chip ?: &no_irq_chip);
50-
irq_put_desc_unlock(desc, flags);
51-
/*
52-
* For !CONFIG_SPARSE_IRQ make the irq show up in
53-
* allocated_irqs.
54-
*/
55-
irq_mark_irq(irq);
56-
return 0;
45+
scoped_irqdesc_get_and_lock(irq, 0) {
46+
scoped_irqdesc->irq_data.chip = (struct irq_chip *)(chip ?: &no_irq_chip);
47+
ret = 0;
48+
}
49+
/* For !CONFIG_SPARSE_IRQ make the irq show up in allocated_irqs. */
50+
if (!ret)
51+
irq_mark_irq(irq);
52+
return ret;
5753
}
5854
EXPORT_SYMBOL(irq_set_chip);
5955

0 commit comments

Comments
 (0)