summaryrefslogtreecommitdiff
path: root/scripts/coccinelle/api/platform_get_irq.cocci
blob: 06b6a95e2bfc63520498c4f73c4840b127097acf (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
// SPDX-License-Identifier: GPL-2.0
/// Remove dev_err() messages after platform_get_irq*() failures
//
// Confidence: Medium
// Options: --include-headers

virtual patch
virtual context
virtual org
virtual report

@depends on context@
expression ret;
struct platform_device *E;
@@

ret =
(
platform_get_irq
|
platform_get_irq_byname
)(E, ...);

if ( \( ret < 0 \| ret <= 0 \) )
{
(
if (ret != -EPROBE_DEFER)
{ ...
*dev_err(...);
... }
|
...
*dev_err(...);
)
...
}

@depends on patch@
expression ret;
struct platform_device *E;
@@

ret =
(
platform_get_irq
|
platform_get_irq_byname
)(E, ...);

if ( \( ret < 0 \| ret <= 0 \) )
{
(
-if (ret != -EPROBE_DEFER)
-{ ...
-dev_err(...);
-... }
|
...
-dev_err(...);
)
...
}

@r depends on org || report@
position p1;
expression ret;
struct platform_device *E;
@@

ret =
(
platform_get_irq
|
platform_get_irq_byname
)(E, ...);

if ( \( ret < 0 \| ret <= 0 \) )
{
(
if (ret != -EPROBE_DEFER)
{ ...
dev_err@p1(...);
... }
|
...
dev_err@p1(...);
)
...
}

@script:python depends on org@
p1 << r.p1;
@@

cocci.print_main(p1)

@script:python depends on report@
p1 << r.p1;
@@

msg = "line %s is redundant because platform_get_irq() already prints an error" % (p1[0].line)
coccilib.report.print_report(p1[0],msg)