File Index
Files and directories
Sign in
FILE

platform_no_drv_owner.cocci

File preview with syntax highlighting.

linux-6.19.14/scripts/coccinelle/api/platform_no_drv_owner.cocci PLAIN TEXT
  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
  7virtual patch
  8virtual context
  9virtual org
 10virtual report
 11
 12@match1@
 13declarer name builtin_i2c_driver;
 14declarer name builtin_platform_driver;
 15declarer name builtin_platform_driver_probe;
 16declarer name module_i2c_driver;
 17declarer name module_platform_driver;
 18declarer name module_platform_driver_probe;
 19identifier __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@
 36identifier 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@
 45identifier match1.__driver;
 46@@
 47	static struct i2c_driver __driver = {
 48		.driver = {
 49-			.owner = THIS_MODULE,
 50		}
 51	};
 52
 53@match2@
 54identifier __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@
 67identifier 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@
 76identifier 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)@
 87identifier match1.__driver;
 88position 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)@
 98identifier match1.__driver;
 99position 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)@
109identifier match2.__driver;
110position 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)@
120identifier match2.__driver;
121position 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@
133j0 << fix1_context.j0;
134@@
135
136msg = "No need to set .owner here. The core will do it."
137coccilib.org.print_todo(j0[0], msg)
138
139@script:python fix1_i2c_org depends on org@
140j0 << fix1_i2c_context.j0;
141@@
142
143msg = "No need to set .owner here. The core will do it."
144coccilib.org.print_todo(j0[0], msg)
145
146@script:python fix2_org depends on org@
147j0 << fix2_context.j0;
148@@
149
150msg = "No need to set .owner here. The core will do it."
151coccilib.org.print_todo(j0[0], msg)
152
153@script:python fix2_i2c_org depends on org@
154j0 << fix2_i2c_context.j0;
155@@
156
157msg = "No need to set .owner here. The core will do it."
158coccilib.org.print_todo(j0[0], msg)
159
160// ----------------------------------------------------------------------------
161
162@script:python fix1_report depends on report@
163j0 << fix1_context.j0;
164@@
165
166msg = "No need to set .owner here. The core will do it."
167coccilib.report.print_report(j0[0], msg)
168
169@script:python fix1_i2c_report depends on report@
170j0 << fix1_i2c_context.j0;
171@@
172
173msg = "No need to set .owner here. The core will do it."
174coccilib.report.print_report(j0[0], msg)
175
176@script:python fix2_report depends on report@
177j0 << fix2_context.j0;
178@@
179
180msg = "No need to set .owner here. The core will do it."
181coccilib.report.print_report(j0[0], msg)
182
183@script:python fix2_i2c_report depends on report@
184j0 << fix2_i2c_context.j0;
185@@
186
187msg = "No need to set .owner here. The core will do it."
188coccilib.report.print_report(j0[0], msg)
189
~/ Read-only file preview.