Release coccinelle-0.1.9-rc1
[bpt/coccinelle.git] / tests / request_irq_sgrep.cocci
CommitLineData
34e49164
C
1// sgrep
2
3// Case 1: search for irq functions where interrupt.h is not used
4// these might be ok as is, because some definitions of request_irq still
5// have the pt_regs parameter in the signature
6
7@ rule1 @
8@@
9
10#include <linux/interrupt.h>
11
12@ rule2 depends on !rule1 @
13expression irq;
14identifier handler;
15expression irqflags;
16expression devname;
17expression dev_id;
18@@
19
20request_irq(irq, handler, irqflags, devname, dev_id)
21
22@@
23identifier rule2.handler, irq, dev, regs;
24@@
25
26* handler(int irq, void *dev, struct pt_regs *regs)
27 { ... }
28
29// ----------------------------------------------------------------------
30
31// Case 2: the function is not static. This only works when there is no
32// static handler function in the file, but fortunately this is the case
33// (we have detected this by actually doing the transformation, which makes
34// the second rule no longer match; unfortunately there is no disjunction
35// at the function level)
36
37@ rule3 depends on rule1 @
38expression irq;
39identifier handler;
40expression irqflags;
41expression devname;
42expression dev_id;
43@@
44
45request_irq(irq, handler, irqflags, devname, dev_id)
46
47@ rule4 @
48typedef irqreturn_t;
49identifier rule3.handler, irq, dev, regs;
50@@
51
52 static irqreturn_t handler(int irq, void *dev, struct pt_regs *regs)
53 { ... }
54
55@ rule5 depends on !rule4 @
56identifier rule3.handler, irq, dev, regs;
57@@
58
59* handler(int irq, void *dev, struct pt_regs *regs)
60 { ... }
61
62// ----------------------------------------------------------------------
63
64// Case 3: the code contains a reference to the regs parameter
65
66@@
67identifier rule3.handler, irq, dev, regs;
68int E;
69@@
70
71 handler(int irq, void *dev, struct pt_regs *regs)
72 {
73 <...
74(
75 handle_irq(E,regs)
76|
77* regs
78)
79 ...>
80 }