Skip to content

Commit 508bd94

Browse files
committed
genirq/manage: Rework enable_percpu_irq()
Use the new guards to get and lock the interrupt descriptor and tidy up the code. 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 90140d0 commit 508bd94

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

kernel/irq/manage.c

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,35 +2286,25 @@ int request_nmi(unsigned int irq, irq_handler_t handler,
22862286

22872287
void enable_percpu_irq(unsigned int irq, unsigned int type)
22882288
{
2289-
unsigned int cpu = smp_processor_id();
2290-
unsigned long flags;
2291-
struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_PERCPU);
2292-
2293-
if (!desc)
2294-
return;
2295-
2296-
/*
2297-
* If the trigger type is not specified by the caller, then
2298-
* use the default for this interrupt.
2299-
*/
2300-
type &= IRQ_TYPE_SENSE_MASK;
2301-
if (type == IRQ_TYPE_NONE)
2302-
type = irqd_get_trigger_type(&desc->irq_data);
2303-
2304-
if (type != IRQ_TYPE_NONE) {
2305-
int ret;
2306-
2307-
ret = __irq_set_trigger(desc, type);
2289+
scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_PERCPU) {
2290+
struct irq_desc *desc = scoped_irqdesc;
23082291

2309-
if (ret) {
2310-
WARN(1, "failed to set type for IRQ%d\n", irq);
2311-
goto out;
2292+
/*
2293+
* If the trigger type is not specified by the caller, then
2294+
* use the default for this interrupt.
2295+
*/
2296+
type &= IRQ_TYPE_SENSE_MASK;
2297+
if (type == IRQ_TYPE_NONE)
2298+
type = irqd_get_trigger_type(&desc->irq_data);
2299+
2300+
if (type != IRQ_TYPE_NONE) {
2301+
if (__irq_set_trigger(desc, type)) {
2302+
WARN(1, "failed to set type for IRQ%d\n", irq);
2303+
return;
2304+
}
23122305
}
2306+
irq_percpu_enable(desc, smp_processor_id());
23132307
}
2314-
2315-
irq_percpu_enable(desc, cpu);
2316-
out:
2317-
irq_put_desc_unlock(desc, flags);
23182308
}
23192309
EXPORT_SYMBOL_GPL(enable_percpu_irq);
23202310

0 commit comments

Comments
 (0)