diff options
Diffstat (limited to 'scripts/coccinelle')
-rw-r--r-- | scripts/coccinelle/api/platform_no_drv_owner.cocci | 106 |
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 | |||
6 | virtual patch | ||
7 | virtual context | ||
8 | virtual org | ||
9 | virtual report | ||
10 | |||
11 | @match1@ | ||
12 | declarer name module_platform_driver; | ||
13 | declarer name module_platform_driver_probe; | ||
14 | identifier __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@ | ||
23 | identifier match1.__driver; | ||
24 | @@ | ||
25 | static struct platform_driver __driver = { | ||
26 | .driver = { | ||
27 | - .owner = THIS_MODULE, | ||
28 | } | ||
29 | }; | ||
30 | |||
31 | @match2@ | ||
32 | identifier __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@ | ||
43 | identifier 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)@ | ||
54 | identifier match1.__driver; | ||
55 | position 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)@ | ||
65 | identifier match2.__driver; | ||
66 | position 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@ | ||
78 | j0 << fix1_context.j0; | ||
79 | @@ | ||
80 | |||
81 | msg = "No need to set .owner here. The core will do it." | ||
82 | coccilib.org.print_todo(j0[0], msg) | ||
83 | |||
84 | @script:python fix2_org depends on org@ | ||
85 | j0 << fix2_context.j0; | ||
86 | @@ | ||
87 | |||
88 | msg = "No need to set .owner here. The core will do it." | ||
89 | coccilib.org.print_todo(j0[0], msg) | ||
90 | |||
91 | // ---------------------------------------------------------------------------- | ||
92 | |||
93 | @script:python fix1_report depends on report@ | ||
94 | j0 << fix1_context.j0; | ||
95 | @@ | ||
96 | |||
97 | msg = "No need to set .owner here. The core will do it." | ||
98 | coccilib.report.print_report(j0[0], msg) | ||
99 | |||
100 | @script:python fix2_report depends on report@ | ||
101 | j0 << fix2_context.j0; | ||
102 | @@ | ||
103 | |||
104 | msg = "No need to set .owner here. The core will do it." | ||
105 | coccilib.report.print_report(j0[0], msg) | ||
106 | |||