]> git.ipfire.org Git - thirdparty/linux.git/blame - scripts/coccinelle/api/pm_runtime.cocci
update Coccinelle URL
[thirdparty/linux.git] / scripts / coccinelle / api / pm_runtime.cocci
CommitLineData
7f904d7e 1// SPDX-License-Identifier: GPL-2.0-only
79f0345f 2/// Make sure pm_runtime_* calls does not use unnecessary IS_ERR_VALUE
f9beafc9 3///
79f0345f
NM
4// Keywords: pm_runtime
5// Confidence: Medium
7f904d7e 6// Copyright (C) 2013 Texas Instruments Incorporated -
f01701ce 7// URL: https://coccinelle.gitlabpages.inria.fr/website
79f0345f
NM
8// Options: --include-headers
9
10virtual patch
11virtual context
12virtual org
13virtual report
14
15//----------------------------------------------------------
16// Detection
17//----------------------------------------------------------
18
19@runtime_bad_err_handle exists@
20expression ret;
d97629f1 21position p;
79f0345f
NM
22@@
23(
d97629f1 24ret@p = \(pm_runtime_idle\|
79f0345f
NM
25 pm_runtime_suspend\|
26 pm_runtime_autosuspend\|
27 pm_runtime_resume\|
28 pm_request_idle\|
29 pm_request_resume\|
30 pm_request_autosuspend\|
31 pm_runtime_get\|
32 pm_runtime_get_sync\|
33 pm_runtime_put\|
34 pm_runtime_put_autosuspend\|
35 pm_runtime_put_sync\|
36 pm_runtime_put_sync_suspend\|
37 pm_runtime_put_sync_autosuspend\|
38 pm_runtime_set_active\|
39 pm_schedule_suspend\|
40 pm_runtime_barrier\|
41 pm_generic_runtime_suspend\|
42 pm_generic_runtime_resume\)(...);
43...
44IS_ERR_VALUE(ret)
45...
46)
47
48//----------------------------------------------------------
49// For context mode
50//----------------------------------------------------------
51
d97629f1 52@depends on context@
79f0345f
NM
53identifier pm_runtime_api;
54expression ret;
d97629f1 55position runtime_bad_err_handle.p;
79f0345f
NM
56@@
57(
d97629f1 58ret@p = pm_runtime_api(...);
79f0345f
NM
59...
60* IS_ERR_VALUE(ret)
61...
62)
63
64//----------------------------------------------------------
65// For patch mode
66//----------------------------------------------------------
67
d97629f1 68@depends on patch@
79f0345f
NM
69identifier pm_runtime_api;
70expression ret;
d97629f1 71position runtime_bad_err_handle.p;
79f0345f
NM
72@@
73(
d97629f1 74ret@p = pm_runtime_api(...);
79f0345f
NM
75...
76- IS_ERR_VALUE(ret)
77+ ret < 0
78...
79)
80
81//----------------------------------------------------------
82// For org and report mode
83//----------------------------------------------------------
84
d97629f1 85@r depends on (org || report) exists@
79f0345f
NM
86position p1, p2;
87identifier pm_runtime_api;
88expression ret;
d97629f1 89position runtime_bad_err_handle.p;
79f0345f
NM
90@@
91(
d97629f1 92ret@p = pm_runtime_api@p1(...);
79f0345f
NM
93...
94IS_ERR_VALUE@p2(ret)
95...
96)
97
98@script:python depends on org@
99p1 << r.p1;
100p2 << r.p2;
101pm_runtime_api << r.pm_runtime_api;
102@@
103
104cocci.print_main(pm_runtime_api,p1)
105cocci.print_secs("IS_ERR_VALUE",p2)
106
107@script:python depends on report@
108p1 << r.p1;
109p2 << r.p2;
110pm_runtime_api << r.pm_runtime_api;
111@@
112
113msg = "%s returns < 0 as error. Unecessary IS_ERR_VALUE at line %s" % (pm_runtime_api, p2[0].line)
114coccilib.report.print_report(p1[0],msg)