Re: [tip:irq/genirq] irq: refactor and clean up the free_irq()code flow
From: Ingo Molnar
Date: Tue Feb 17 2009 - 14:46:55 EST
* Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> 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.
Ah, good point. I concentrated on an identity transformation
primarily and missed that simplification.
Something like the patch below? (plus the followup cleanup
further below?)
Ingo
------------->