Re: [patch V2 35/45] genirq/manage: Rework irq_set_irq_wake()

Thomas Gleixner
2025-04-30T12:42:54Z

On Wed, Apr 30 2025 at 08:37, Jiri Slaby wrote:
> On 29. 04. 25, 8:55, Thomas Gleixner wrote:
>> Use the new guards to get and lock the interrupt descriptor and tidy up the
>> code.
>> - unsigned long flags;
>> - struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
>> - int ret = 0;
>> + int ret = -EINVAL;
>
> Hmm...
>
>> - if (!desc)
>> - return -EINVAL;
>> + scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_GLOBAL) {
>> + struct irq_desc *desc = scoped_irqdesc;
>>
>> + /*
>> + * wakeup-capable irqs can be shared between drivers that
>> + * don't need to have the same sleep mode behaviors.
>> + */
>> + if (on) {
>> + if (desc->wake_depth++ == 0) {
>> + ret = set_irq_wake_real(irq, on);
>> + if (ret)
>> + desc->wake_depth = 0;
>> + else
>> + irqd_set(&desc->irq_data, IRQD_WAKEUP_STATE);
>> + }
>
> So in this (imaginary) else branch (i.e. desc->wake_depth++ != 0), you
> return EINVAL now?
>
> Previously, it was 0 (correctly), if I am looking correctly.

Duh, yes.