aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWolfram Sang <wsa@the-dreams.de>2014-10-28 12:40:43 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-11-06 18:16:02 -0500
commit1f648f88cea7f9b16ea8964cd81b92fb08df75a5 (patch)
treeeb745115f3216e1297aa258d0fdffd83fa6735e2
parent291f653a140ad880426125e5e9dbb70f4c184683 (diff)
coccinelle: api: add spatch to prevent unnecessary .owner
There are calls which silently set the owner of a module. This is the preferred way [1], so avoid setting it manually. Currently, we only care about platform drivers, but there might be more calls to be added later. [1] https://lkml.org/lkml/2014/10/12/87 Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-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