Commit | Line | Data |
---|---|---|
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 @ | |
13 | expression irq; | |
14 | identifier handler; | |
15 | expression irqflags; | |
16 | expression devname; | |
17 | expression dev_id; | |
18 | @@ | |
19 | ||
20 | request_irq(irq, handler, irqflags, devname, dev_id) | |
21 | ||
22 | @@ | |
23 | identifier 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 @ | |
38 | expression irq; | |
39 | identifier handler; | |
40 | expression irqflags; | |
41 | expression devname; | |
42 | expression dev_id; | |
43 | @@ | |
44 | ||
45 | request_irq(irq, handler, irqflags, devname, dev_id) | |
46 | ||
47 | @ rule4 @ | |
48 | typedef irqreturn_t; | |
49 | identifier 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 @ | |
56 | identifier 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 | @@ | |
67 | identifier rule3.handler, irq, dev, regs; | |
68 | int 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 | } |