Debian Codegraph @

scripts/coccinelle/api/platform_no_drv_owner.cocci

raw
1 // SPDX-License-Identifier: GPL-2.0-only
2 /// Remove .owner field if calls are used which set it automatically
3 ///
4 // Confidence: High
5 // Copyright: (C) 2014 Wolfram Sang.
6
7 virtual patch
8 virtual context
9 virtual org
10 virtual report
11
12 @match1@
13 declarer name builtin_i2c_driver;
14 declarer name builtin_platform_driver;
15 declarer name builtin_platform_driver_probe;
16 declarer name module_i2c_driver;
17 declarer name module_platform_driver;
18 declarer name module_platform_driver_probe;
19 identifier __driver;
20 @@
21 (
22 builtin_i2c_driver(__driver);
23 |
24 builtin_platform_driver(__driver);
25 |
26 builtin_platform_driver_probe(__driver, ...);
27 |
28 module_i2c_driver(__driver);
29 |
30 module_platform_driver(__driver);
31 |
32 module_platform_driver_probe(__driver, ...);
33 )
34
35 @fix1 depends on match1 && patch && !context && !org && !report@
36 identifier match1.__driver;
37 @@
38 static struct platform_driver __driver = {
39 .driver = {
40 - .owner = THIS_MODULE,
41 }
42 };
43
44 @fix1_i2c depends on match1 && patch && !context && !org && !report@
45 identifier match1.__driver;
46 @@
47 static struct i2c_driver __driver = {
48 .driver = {
49 - .owner = THIS_MODULE,
50 }
51 };
52
53 @match2@
54 identifier __driver;
55 @@
56 (
57 platform_driver_register(&__driver)
58 |
59 platform_driver_probe(&__driver, ...)
60 |
61 platform_create_bundle(&__driver, ...)
62 |
63 i2c_add_driver(&__driver)
64 )
65
66 @fix2 depends on match2 && patch && !context && !org && !report@
67 identifier match2.__driver;
68 @@
69 static struct platform_driver __driver = {
70 .driver = {
71 - .owner = THIS_MODULE,
72 }
73 };
74
75 @fix2_i2c depends on match2 && patch && !context && !org && !report@
76 identifier match2.__driver;
77 @@
78 static struct i2c_driver __driver = {
79 .driver = {
80 - .owner = THIS_MODULE,
81 }
82 };
83
84 // ----------------------------------------------------------------------------
85
86 @fix1_context depends on match1 && !patch && (context || org || report)@
87 identifier match1.__driver;
88 position j0;
89 @@
90
91 static struct platform_driver __driver = {
92 .driver = {
93 * .owner@j0 = THIS_MODULE,
94 }
95 };
96
97 @fix1_i2c_context depends on match1 && !patch && (context || org || report)@
98 identifier match1.__driver;
99 position j0;
100 @@
101
102 static struct i2c_driver __driver = {
103 .driver = {
104 * .owner@j0 = THIS_MODULE,
105 }
106 };
107
108 @fix2_context depends on match2 && !patch && (context || org || report)@
109 identifier match2.__driver;
110 position j0;
111 @@
112
113 static struct platform_driver __driver = {
114 .driver = {
115 * .owner@j0 = THIS_MODULE,
116 }
117 };
118
119 @fix2_i2c_context depends on match2 && !patch && (context || org || report)@
120 identifier match2.__driver;
121 position j0;
122 @@
123
124 static struct i2c_driver __driver = {
125 .driver = {
126 * .owner@j0 = THIS_MODULE,
127 }
128 };
129
130 // ----------------------------------------------------------------------------
131
132 @script:python fix1_org depends on org@
133 j0 << fix1_context.j0;
134 @@
135
136 msg = "No need to set .owner here. The core will do it."
137 coccilib.org.print_todo(j0[0], msg)
138
139 @script:python fix1_i2c_org depends on org@
140 j0 << fix1_i2c_context.j0;
141 @@
142
143 msg = "No need to set .owner here. The core will do it."
144 coccilib.org.print_todo(j0[0], msg)
145
146 @script:python fix2_org depends on org@
147 j0 << fix2_context.j0;
148 @@
149
150 msg = "No need to set .owner here. The core will do it."
151 coccilib.org.print_todo(j0[0], msg)
152
153 @script:python fix2_i2c_org depends on org@
154 j0 << fix2_i2c_context.j0;
155 @@
156
157 msg = "No need to set .owner here. The core will do it."
158 coccilib.org.print_todo(j0[0], msg)
159
160 // ----------------------------------------------------------------------------
161
162 @script:python fix1_report depends on report@
163 j0 << fix1_context.j0;
164 @@
165
166 msg = "No need to set .owner here. The core will do it."
167 coccilib.report.print_report(j0[0], msg)
168
169 @script:python fix1_i2c_report depends on report@
170 j0 << fix1_i2c_context.j0;
171 @@
172
173 msg = "No need to set .owner here. The core will do it."
174 coccilib.report.print_report(j0[0], msg)
175
176 @script:python fix2_report depends on report@
177 j0 << fix2_context.j0;
178 @@
179
180 msg = "No need to set .owner here. The core will do it."
181 coccilib.report.print_report(j0[0], msg)
182
183 @script:python fix2_i2c_report depends on report@
184 j0 << fix2_i2c_context.j0;
185 @@
186
187 msg = "No need to set .owner here. The core will do it."
188 coccilib.report.print_report(j0[0], msg)
189