aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/coccinelle
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/coccinelle')
-rw-r--r--scripts/coccinelle/api/platform_no_drv_owner.cocci106
1 files changed, 106 insertions, 0 deletions
diff --git a/scripts/coccinelle/api/platform_no_drv_owner.cocci b/scripts/coccinelle/api/platform_no_drv_owner.cocci
new file mode 100644
index 000000000000..e065b9e714fc
--- /dev/null
+++ b/scripts/coccinelle/api/platform_no_drv_owner.cocci
@@ -0,0 +1,106 @@
1/// Remove .owner field if calls are used which set it automatically
2///
3// Confidence: High
4// Copyright: (C) 2014 Wolfram Sang. GPL v2.
5
6virtual patch
7virtual context
8virtual org
9virtual report
10
11@match1@
12declarer name module_platform_driver;
13declarer name module_platform_driver_probe;
14identifier __driver;
15@@
16(
17 module_platform_driver(__driver);
18|
19 module_platform_driver_probe(__driver, ...);
20)
21
22@fix1 depends on match1 && patch && !context && !org && !report@
23identifier match1.__driver;
24@@
25 static struct platform_driver __driver = {
26 .driver = {
27- .owner = THIS_MODULE,
28 }
29 };
30
31@match2@
32identifier __driver;
33@@
34(
35 platform_driver_register(&__driver)
36|
37 platform_driver_probe(&__driver, ...)
38|
39 platform_create_bundle(&__driver, ...)
40)
41
42@fix2 depends on match2 && patch && !context && !org && !report@
43identifier match2.__driver;
44@@
45 static struct platform_driver __driver = {
46 .driver = {
47- .owner = THIS_MODULE,
48 }
49 };
50
51// ----------------------------------------------------------------------------
52
53@fix1_context depends on match1 && !patch && (context || org || report)@
54identifier match1.__driver;
55position j0;
56@@
57
58 static struct platform_driver __driver = {
59 .driver = {
60* .owner@j0 = THIS_MODULE,
61 }
62 };
63
64@fix2_context depends on match2 && !patch && (context || org || report)@
65identifier match2.__driver;
66position j0;
67@@
68
69 static struct platform_driver __driver = {
70 .driver = {
71* .owner@j0 = THIS_MODULE,
72 }
73 };
74
75// ----------------------------------------------------------------------------
76
77@script:python fix1_org depends on org@
78j0 << fix1_context.j0;
79@@
80
81msg = "No need to set .owner here. The core will do it."
82coccilib.org.print_todo(j0[0], msg)
83
84@script:python fix2_org depends on org@
85j0 << fix2_context.j0;
86@@
87
88msg = "No need to set .owner here. The core will do it."
89coccilib.org.print_todo(j0[0], msg)
90
91// ----------------------------------------------------------------------------
92
93@script:python fix1_report depends on report@
94j0 << fix1_context.j0;
95@@
96
97msg = "No need to set .owner here. The core will do it."
98coccilib.report.print_report(j0[0], msg)
99
100@script:python fix2_report depends on report@
101j0 << fix2_context.j0;
102@@
103
104msg = "No need to set .owner here. The core will do it."
105coccilib.report.print_report(j0[0], msg)
106