platform_no_drv_owner.cocci 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. virtual patch
  7. virtual context
  8. virtual org
  9. virtual report
  10. @match1@
  11. declarer name module_i2c_driver;
  12. declarer name module_platform_driver;
  13. declarer name module_platform_driver_probe;
  14. identifier __driver;
  15. @@
  16. (
  17. module_i2c_driver(__driver);
  18. |
  19. module_platform_driver(__driver);
  20. |
  21. module_platform_driver_probe(__driver, ...);
  22. )
  23. @fix1 depends on match1 && patch && !context && !org && !report@
  24. identifier match1.__driver;
  25. @@
  26. static struct platform_driver __driver = {
  27. .driver = {
  28. - .owner = THIS_MODULE,
  29. }
  30. };
  31. @fix1_i2c depends on match1 && patch && !context && !org && !report@
  32. identifier match1.__driver;
  33. @@
  34. static struct i2c_driver __driver = {
  35. .driver = {
  36. - .owner = THIS_MODULE,
  37. }
  38. };
  39. @match2@
  40. identifier __driver;
  41. @@
  42. (
  43. platform_driver_register(&__driver)
  44. |
  45. platform_driver_probe(&__driver, ...)
  46. |
  47. platform_create_bundle(&__driver, ...)
  48. |
  49. i2c_add_driver(&__driver)
  50. )
  51. @fix2 depends on match2 && patch && !context && !org && !report@
  52. identifier match2.__driver;
  53. @@
  54. static struct platform_driver __driver = {
  55. .driver = {
  56. - .owner = THIS_MODULE,
  57. }
  58. };
  59. @fix2_i2c depends on match2 && patch && !context && !org && !report@
  60. identifier match2.__driver;
  61. @@
  62. static struct i2c_driver __driver = {
  63. .driver = {
  64. - .owner = THIS_MODULE,
  65. }
  66. };
  67. // ----------------------------------------------------------------------------
  68. @fix1_context depends on match1 && !patch && (context || org || report)@
  69. identifier match1.__driver;
  70. position j0;
  71. @@
  72. static struct platform_driver __driver = {
  73. .driver = {
  74. * .owner@j0 = THIS_MODULE,
  75. }
  76. };
  77. @fix1_i2c_context depends on match1 && !patch && (context || org || report)@
  78. identifier match1.__driver;
  79. position j0;
  80. @@
  81. static struct i2c_driver __driver = {
  82. .driver = {
  83. * .owner@j0 = THIS_MODULE,
  84. }
  85. };
  86. @fix2_context depends on match2 && !patch && (context || org || report)@
  87. identifier match2.__driver;
  88. position j0;
  89. @@
  90. static struct platform_driver __driver = {
  91. .driver = {
  92. * .owner@j0 = THIS_MODULE,
  93. }
  94. };
  95. @fix2_i2c_context depends on match2 && !patch && (context || org || report)@
  96. identifier match2.__driver;
  97. position j0;
  98. @@
  99. static struct i2c_driver __driver = {
  100. .driver = {
  101. * .owner@j0 = THIS_MODULE,
  102. }
  103. };
  104. // ----------------------------------------------------------------------------
  105. @script:python fix1_org depends on org@
  106. j0 << fix1_context.j0;
  107. @@
  108. msg = "No need to set .owner here. The core will do it."
  109. coccilib.org.print_todo(j0[0], msg)
  110. @script:python fix1_i2c_org depends on org@
  111. j0 << fix1_i2c_context.j0;
  112. @@
  113. msg = "No need to set .owner here. The core will do it."
  114. coccilib.org.print_todo(j0[0], msg)
  115. @script:python fix2_org depends on org@
  116. j0 << fix2_context.j0;
  117. @@
  118. msg = "No need to set .owner here. The core will do it."
  119. coccilib.org.print_todo(j0[0], msg)
  120. @script:python fix2_i2c_org depends on org@
  121. j0 << fix2_i2c_context.j0;
  122. @@
  123. msg = "No need to set .owner here. The core will do it."
  124. coccilib.org.print_todo(j0[0], msg)
  125. // ----------------------------------------------------------------------------
  126. @script:python fix1_report depends on report@
  127. j0 << fix1_context.j0;
  128. @@
  129. msg = "No need to set .owner here. The core will do it."
  130. coccilib.report.print_report(j0[0], msg)
  131. @script:python fix1_i2c_report depends on report@
  132. j0 << fix1_i2c_context.j0;
  133. @@
  134. msg = "No need to set .owner here. The core will do it."
  135. coccilib.report.print_report(j0[0], msg)
  136. @script:python fix2_report depends on report@
  137. j0 << fix2_context.j0;
  138. @@
  139. msg = "No need to set .owner here. The core will do it."
  140. coccilib.report.print_report(j0[0], msg)
  141. @script:python fix2_i2c_report depends on report@
  142. j0 << fix2_i2c_context.j0;
  143. @@
  144. msg = "No need to set .owner here. The core will do it."
  145. coccilib.report.print_report(j0[0], msg)