summaryrefslogtreecommitdiffstats
path: root/scripts/coccinelle/misc/irqf_oneshot.cocci
blob: 9b6f404d07f20a8c51b822291aebc3b553a56c13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// SPDX-License-Identifier: GPL-2.0
/// Since commit 1c6c69525b40 ("genirq: Reject bogus threaded irq requests")
/// threaded IRQs without a primary handler need to be requested with
/// IRQF_ONESHOT, otherwise the request will fail.
///
/// So pass the IRQF_ONESHOT flag in this case.
///
//
// Confidence: Moderate
// Comments:
// Options: --no-includes

virtual patch
virtual context
virtual org
virtual report

@r1@
expression dev, irq, thread_fn;
position p;
@@
(
request_threaded_irq@p(irq, NULL, thread_fn,
(
IRQF_ONESHOT | ...
|
IRQF_ONESHOT
)
, ...)
|
devm_request_threaded_irq@p(dev, irq, NULL, thread_fn,
(
IRQF_ONESHOT | ...
|
IRQF_ONESHOT
)
, ...)
)

@r2@
expression dev, irq, thread_fn, flags, e;
position p != r1.p;
@@
(
flags = IRQF_ONESHOT | ...
|
flags |= IRQF_ONESHOT | ...
)
... when != flags = e
(
request_threaded_irq@p(irq, NULL, thread_fn, flags, ...);
|
devm_request_threaded_irq@p(dev, irq, NULL, thread_fn, flags, ...);
)

@depends on patch@
expression dev, irq, thread_fn, flags;
position p != {r1.p,r2.p};
@@
(
request_threaded_irq@p(irq, NULL, thread_fn,
(
-0
+IRQF_ONESHOT
|
-flags
+flags | IRQF_ONESHOT
)
, ...)
|
devm_request_threaded_irq@p(dev, irq, NULL, thread_fn,
(
-0
+IRQF_ONESHOT
|
-flags
+flags | IRQF_ONESHOT
)
, ...)
)

@depends on context@
expression dev, irq;
position p != {r1.p,r2.p};
@@
(
*request_threaded_irq@p(irq, NULL, ...)
|
*devm_request_threaded_irq@p(dev, irq, NULL, ...)
)


@match depends on report || org@
expression dev, irq;
position p != {r1.p,r2.p};
@@
(
request_threaded_irq@p(irq, NULL, ...)
|
devm_request_threaded_irq@p(dev, irq, NULL, ...)
)

@script:python depends on org@
p << match.p;
@@
msg = "WARNING: Threaded IRQ with no primary handler requested without IRQF_ONESHOT (unless it is nested IRQ)"
coccilib.org.print_todo(p[0],msg)

@script:python depends on report@
p << match.p;
@@
msg = "WARNING: Threaded IRQ with no primary handler requested without IRQF_ONESHOT (unless it is nested IRQ)"
coccilib.report.print_report(p[0],msg)