drm-get-put.cocci 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // SPDX-License-Identifier: GPL-2.0
  2. ///
  3. /// Use drm_*_get() and drm_*_put() helpers instead of drm_*_reference() and
  4. /// drm_*_unreference() helpers.
  5. ///
  6. // Confidence: High
  7. // Copyright: (C) 2017 NVIDIA Corporation
  8. // Options: --no-includes --include-headers
  9. //
  10. virtual patch
  11. virtual report
  12. @depends on patch@
  13. expression object;
  14. @@
  15. (
  16. - drm_mode_object_reference(object)
  17. + drm_mode_object_get(object)
  18. |
  19. - drm_mode_object_unreference(object)
  20. + drm_mode_object_put(object)
  21. |
  22. - drm_connector_reference(object)
  23. + drm_connector_get(object)
  24. |
  25. - drm_connector_unreference(object)
  26. + drm_connector_put(object)
  27. |
  28. - drm_framebuffer_reference(object)
  29. + drm_framebuffer_get(object)
  30. |
  31. - drm_framebuffer_unreference(object)
  32. + drm_framebuffer_put(object)
  33. |
  34. - drm_gem_object_reference(object)
  35. + drm_gem_object_get(object)
  36. |
  37. - drm_gem_object_unreference(object)
  38. + drm_gem_object_put(object)
  39. |
  40. - __drm_gem_object_unreference(object)
  41. + __drm_gem_object_put(object)
  42. |
  43. - drm_gem_object_unreference_unlocked(object)
  44. + drm_gem_object_put_unlocked(object)
  45. |
  46. - drm_property_reference_blob(object)
  47. + drm_property_blob_get(object)
  48. |
  49. - drm_property_unreference_blob(object)
  50. + drm_property_blob_put(object)
  51. )
  52. @r depends on report@
  53. expression object;
  54. position p;
  55. @@
  56. (
  57. drm_mode_object_unreference@p(object)
  58. |
  59. drm_mode_object_reference@p(object)
  60. |
  61. drm_connector_unreference@p(object)
  62. |
  63. drm_connector_reference@p(object)
  64. |
  65. drm_framebuffer_unreference@p(object)
  66. |
  67. drm_framebuffer_reference@p(object)
  68. |
  69. drm_gem_object_unreference@p(object)
  70. |
  71. drm_gem_object_reference@p(object)
  72. |
  73. __drm_gem_object_unreference(object)
  74. |
  75. drm_gem_object_unreference_unlocked(object)
  76. |
  77. drm_property_unreference_blob@p(object)
  78. |
  79. drm_property_reference_blob@p(object)
  80. )
  81. @script:python depends on report@
  82. object << r.object;
  83. p << r.p;
  84. @@
  85. msg="WARNING: use get/put helpers to reference and dereference %s" % (object)
  86. coccilib.report.print_report(p[0], msg)