Skip to content

Commit 8589e32

Browse files
committed
genirq/manage: Rework irq_set_irq_wake()
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/87ldrhq0hc.ffs@tglx
1 parent bddd10c commit 8589e32

File tree

1 file changed

+30
-35
lines changed

1 file changed

+30
-35
lines changed

kernel/irq/manage.c

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -846,45 +846,40 @@ static int set_irq_wake_real(unsigned int irq, unsigned int on)
846846
*/
847847
int irq_set_irq_wake(unsigned int irq, unsigned int on)
848848
{
849-
unsigned long flags;
850-
struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
851-
int ret = 0;
852-
853-
if (!desc)
854-
return -EINVAL;
849+
scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_GLOBAL) {
850+
struct irq_desc *desc = scoped_irqdesc;
851+
int ret = 0;
855852

856-
/* Don't use NMIs as wake up interrupts please */
857-
if (irq_is_nmi(desc)) {
858-
ret = -EINVAL;
859-
goto out_unlock;
860-
}
853+
/* Don't use NMIs as wake up interrupts please */
854+
if (irq_is_nmi(desc))
855+
return -EINVAL;
861856

862-
/* wakeup-capable irqs can be shared between drivers that
863-
* don't need to have the same sleep mode behaviors.
864-
*/
865-
if (on) {
866-
if (desc->wake_depth++ == 0) {
867-
ret = set_irq_wake_real(irq, on);
868-
if (ret)
869-
desc->wake_depth = 0;
870-
else
871-
irqd_set(&desc->irq_data, IRQD_WAKEUP_STATE);
872-
}
873-
} else {
874-
if (desc->wake_depth == 0) {
875-
WARN(1, "Unbalanced IRQ %d wake disable\n", irq);
876-
} else if (--desc->wake_depth == 0) {
877-
ret = set_irq_wake_real(irq, on);
878-
if (ret)
879-
desc->wake_depth = 1;
880-
else
881-
irqd_clear(&desc->irq_data, IRQD_WAKEUP_STATE);
857+
/*
858+
* wakeup-capable irqs can be shared between drivers that
859+
* don't need to have the same sleep mode behaviors.
860+
*/
861+
if (on) {
862+
if (desc->wake_depth++ == 0) {
863+
ret = set_irq_wake_real(irq, on);
864+
if (ret)
865+
desc->wake_depth = 0;
866+
else
867+
irqd_set(&desc->irq_data, IRQD_WAKEUP_STATE);
868+
}
869+
} else {
870+
if (desc->wake_depth == 0) {
871+
WARN(1, "Unbalanced IRQ %d wake disable\n", irq);
872+
} else if (--desc->wake_depth == 0) {
873+
ret = set_irq_wake_real(irq, on);
874+
if (ret)
875+
desc->wake_depth = 1;
876+
else
877+
irqd_clear(&desc->irq_data, IRQD_WAKEUP_STATE);
878+
}
882879
}
880+
return ret;
883881
}
884-
885-
out_unlock:
886-
irq_put_desc_busunlock(desc, flags);
887-
return ret;
882+
return -EINVAL;
888883
}
889884
EXPORT_SYMBOL(irq_set_irq_wake);
890885

0 commit comments

Comments
 (0)