aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/coccinelle
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2013-12-02 08:39:41 -0500
committerMichal Marek <mmarek@suse.cz>2014-01-03 08:39:35 -0500
commit79f0345fefaafb7cde301a830471edd21a37989b (patch)
tree5bc7dc2d1bbf6ab5df7d9f9b7a0457c73ac65033 /scripts/coccinelle
parent37e2c2a775fc887acd1432908478dfd532f7f00f (diff)
scripts: Coccinelle script for pm_runtime_* return checks with IS_ERR_VALUE
As indicated by Sekhar in [1], there seems to be a tendency to use IS_ERR_VALUE to check the error result for pm_runtime_* functions which make no sense considering commit c48cd65 (ARM: OMAP: use consistent error checking) - the error values can either be < 0 for error OR 0, 1 in cases where we have success. So, setup a coccinelle script to help identify the same. [1] http://marc.info/?t=138472678100003&r=1&w=2 Cc: Russell King <rmk+kernel@arm.linux.org.uk> Reported-by: Sekhar Nori <nsekhar@ti.com> Signed-off-by: Nishanth Menon <nm@ti.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts/coccinelle')
-rw-r--r--scripts/coccinelle/api/pm_runtime.cocci109
1 files changed, 109 insertions, 0 deletions
diff --git a/scripts/coccinelle/api/pm_runtime.cocci b/scripts/coccinelle/api/pm_runtime.cocci
new file mode 100644
index 000000000000..f01789e967ec
--- /dev/null
+++ b/scripts/coccinelle/api/pm_runtime.cocci
@@ -0,0 +1,109 @@
1/// Make sure pm_runtime_* calls does not use unnecessary IS_ERR_VALUE
2//
3// Keywords: pm_runtime
4// Confidence: Medium
5// Copyright (C) 2013 Texas Instruments Incorporated - GPLv2.
6// URL: http://coccinelle.lip6.fr/
7// Options: --include-headers
8
9virtual patch
10virtual context
11virtual org
12virtual report
13
14//----------------------------------------------------------
15// Detection
16//----------------------------------------------------------
17
18@runtime_bad_err_handle exists@
19expression ret;
20@@
21(
22ret = \(pm_runtime_idle\|
23 pm_runtime_suspend\|
24 pm_runtime_autosuspend\|
25 pm_runtime_resume\|
26 pm_request_idle\|
27 pm_request_resume\|
28 pm_request_autosuspend\|
29 pm_runtime_get\|
30 pm_runtime_get_sync\|
31 pm_runtime_put\|
32 pm_runtime_put_autosuspend\|
33 pm_runtime_put_sync\|
34 pm_runtime_put_sync_suspend\|
35 pm_runtime_put_sync_autosuspend\|
36 pm_runtime_set_active\|
37 pm_schedule_suspend\|
38 pm_runtime_barrier\|
39 pm_generic_runtime_suspend\|
40 pm_generic_runtime_resume\)(...);
41...
42IS_ERR_VALUE(ret)
43...
44)
45
46//----------------------------------------------------------
47// For context mode
48//----------------------------------------------------------
49
50@depends on runtime_bad_err_handle && context@
51identifier pm_runtime_api;
52expression ret;
53@@
54(
55ret = pm_runtime_api(...);
56...
57* IS_ERR_VALUE(ret)
58...
59)
60
61//----------------------------------------------------------
62// For patch mode
63//----------------------------------------------------------
64
65@depends on runtime_bad_err_handle && patch@
66identifier pm_runtime_api;
67expression ret;
68@@
69(
70ret = pm_runtime_api(...);
71...
72- IS_ERR_VALUE(ret)
73+ ret < 0
74...
75)
76
77//----------------------------------------------------------
78// For org and report mode
79//----------------------------------------------------------
80
81@r depends on runtime_bad_err_handle exists@
82position p1, p2;
83identifier pm_runtime_api;
84expression ret;
85@@
86(
87ret = pm_runtime_api@p1(...);
88...
89IS_ERR_VALUE@p2(ret)
90...
91)
92
93@script:python depends on org@
94p1 << r.p1;
95p2 << r.p2;
96pm_runtime_api << r.pm_runtime_api;
97@@
98
99cocci.print_main(pm_runtime_api,p1)
100cocci.print_secs("IS_ERR_VALUE",p2)
101
102@script:python depends on report@
103p1 << r.p1;
104p2 << r.p2;
105pm_runtime_api << r.pm_runtime_api;
106@@
107
108msg = "%s returns < 0 as error. Unecessary IS_ERR_VALUE at line %s" % (pm_runtime_api, p2[0].line)
109coccilib.report.print_report(p1[0],msg)