Skip to content

Commit 95a3645

Browse files
committed
genirq/chip: Rework irq_modify_status()
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 5cd05f3 commit 95a3645

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

kernel/irq/chip.c

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -972,38 +972,34 @@ EXPORT_SYMBOL_GPL(irq_set_chip_and_handler_name);
972972

973973
void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
974974
{
975-
unsigned long flags, trigger, tmp;
976-
struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
977-
978-
if (!desc)
979-
return;
980-
981-
/*
982-
* Warn when a driver sets the no autoenable flag on an already
983-
* active interrupt.
984-
*/
985-
WARN_ON_ONCE(!desc->depth && (set & _IRQ_NOAUTOEN));
986-
987-
irq_settings_clr_and_set(desc, clr, set);
975+
scoped_irqdesc_get_and_lock(irq, 0) {
976+
struct irq_desc *desc = scoped_irqdesc;
977+
unsigned long trigger, tmp;
978+
/*
979+
* Warn when a driver sets the no autoenable flag on an already
980+
* active interrupt.
981+
*/
982+
WARN_ON_ONCE(!desc->depth && (set & _IRQ_NOAUTOEN));
988983

989-
trigger = irqd_get_trigger_type(&desc->irq_data);
984+
irq_settings_clr_and_set(desc, clr, set);
990985

991-
irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU |
992-
IRQD_TRIGGER_MASK | IRQD_LEVEL);
993-
if (irq_settings_has_no_balance_set(desc))
994-
irqd_set(&desc->irq_data, IRQD_NO_BALANCING);
995-
if (irq_settings_is_per_cpu(desc))
996-
irqd_set(&desc->irq_data, IRQD_PER_CPU);
997-
if (irq_settings_is_level(desc))
998-
irqd_set(&desc->irq_data, IRQD_LEVEL);
986+
trigger = irqd_get_trigger_type(&desc->irq_data);
999987

1000-
tmp = irq_settings_get_trigger_mask(desc);
1001-
if (tmp != IRQ_TYPE_NONE)
1002-
trigger = tmp;
988+
irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU |
989+
IRQD_TRIGGER_MASK | IRQD_LEVEL);
990+
if (irq_settings_has_no_balance_set(desc))
991+
irqd_set(&desc->irq_data, IRQD_NO_BALANCING);
992+
if (irq_settings_is_per_cpu(desc))
993+
irqd_set(&desc->irq_data, IRQD_PER_CPU);
994+
if (irq_settings_is_level(desc))
995+
irqd_set(&desc->irq_data, IRQD_LEVEL);
1003996

1004-
irqd_set(&desc->irq_data, trigger);
997+
tmp = irq_settings_get_trigger_mask(desc);
998+
if (tmp != IRQ_TYPE_NONE)
999+
trigger = tmp;
10051000

1006-
irq_put_desc_unlock(desc, flags);
1001+
irqd_set(&desc->irq_data, trigger);
1002+
}
10071003
}
10081004
EXPORT_SYMBOL_GPL(irq_modify_status);
10091005

0 commit comments

Comments
 (0)