Re: [PATCH 06/12] genericirq: make irq_chip related function to take desc

From: Eric W. Biederman
Date: Sun Mar 21 2010 - 00:18:59 EST



I haven't heard anything more on this, but I had reason to play with
coccinelle http://coccinelle.lip6.fr/ which I think is think think is
the semantic patcher you referred to.

In any case I was playing with it and I believe I have managed to whip
up a fairly robust semantic patch. The last two hunks are to cleanup
earlier transforms, by removing unnecessary irq_to_desc chatter, and
removing unused variables. I am a big grumpy that I couldn't figure
out how to add comments to my patch to explain the tricky bits,
but otherwise I am happy.

The patch appears to have the limitation that methods that are not in
the file where struct irq_chip is defined, which is an issue for the
msi irq_chip helper routines. Other than that I don't know of any
issues.

I would suggest changing as much of the x86 non irq_chip helpers to
use irq_desc before applying this so it this the conversion can have
the chance to remove any irq variables.

Eric


@ DECL @
struct irq_chip CHIP;
identifier METHOD;
identifier METHOD_NAME;
@@
CHIP.METHOD_NAME = METHOD;

@ @
identifier DECL.METHOD;
identifier IRQ;
@@
METHOD(
- unsigned int IRQ
+ struct irq_desc *unused
, ...) {
}

@ @
identifier DECL.METHOD;
identifier IRQ;
identifier DESC;
@@
METHOD(
- unsigned int IRQ
+ struct irq_desc *DESC
, ...) {
+ unsigned int IRQ = DESC->irq;
...
- struct irq_desc *DESC = irq_to_desc(IRQ);
...
}

@ @
identifier DECL.METHOD;
identifier IRQ;
identifier DESC;
@@
METHOD(
- unsigned int IRQ
+ struct irq_desc *DESC
, ...) {
+ unsigned int IRQ = DESC->irq;
...
- struct irq_desc *DESC;
...
- DESC = irq_to_desc(IRQ);
...
}

@ @
identifier DECL.METHOD;
identifier IRQ;
@@
METHOD(
- unsigned int IRQ
+ struct irq_desc *desc
, ...) {
+ unsigned int IRQ = desc->irq;
...
}

@ @
identifier DECL.METHOD;
identifier FUNC;
identifier IRQ;
@@
FUNC(...) {
<...
METHOD(
- IRQ
+ irq_to_desc(IRQ)
, ... )
...>
}

@ @
identifier FUNC;
identifier DESC;
identifier IRQ;
@@
FUNC(..., struct irq_desc *DESC, ...) {
...
unsigned int IRQ = DESC->irq;
<...
- irq_to_desc(IRQ)
+ DESC
...>
}

@ @
identifier FUNC;
identifier DESC;
identifier IRQ;
@@
FUNC(..., struct irq_desc *DESC, ...) {
...
- unsigned int IRQ = DESC->irq;
... when != IRQ
}
--
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/