Re: [tip:irq/genirq] irq: refactor and clean up the free_irq() codeflow

From: Linus Torvalds
Date: Tue Feb 17 2009 - 14:05:26 EST




On Sun, 15 Feb 2009, Ingo Molnar wrote:
> struct irq_desc *desc = irq_to_desc(irq);
> - struct irqaction **p;
> + struct irqaction *action, **p, **pp;

The whole reason for 'pp' seems to be the confusing loop:

> for (;;) {
> + action = *p;
> + pp = p;
> +
> + if (!action) {
> + WARN(1, "Trying to free already-free IRQ %d\n", irq);
> + spin_unlock_irqrestore(&desc->lock, flags);
> +
> + return;
> + }
>
> + p = &action->next;
> + if (action->dev_id != dev_id)
> + continue;
>
> + break;
> + }
> + /* Found it - now remove it from the list of entries: */
> + *pp = action->next;

Where the need for 'pp' would go away if you'd just write it as

if (action->dev_id == dev_id)
break;
p = &action->next;
}
*p = action->next;

instead. Which also makes it both shorter and more readable.

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/