platform_no_drv_owner.cocci 3.8 KB

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