drm-get-put.cocci 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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_connector_reference(object)
  17. + drm_connector_get(object)
  18. |
  19. - drm_connector_unreference(object)
  20. + drm_connector_put(object)
  21. |
  22. - drm_framebuffer_reference(object)
  23. + drm_framebuffer_get(object)
  24. |
  25. - drm_framebuffer_unreference(object)
  26. + drm_framebuffer_put(object)
  27. |
  28. - drm_gem_object_reference(object)
  29. + drm_gem_object_get(object)
  30. |
  31. - drm_gem_object_unreference(object)
  32. + drm_gem_object_put(object)
  33. |
  34. - __drm_gem_object_unreference(object)
  35. + __drm_gem_object_put(object)
  36. |
  37. - drm_gem_object_unreference_unlocked(object)
  38. + drm_gem_object_put_unlocked(object)
  39. |
  40. - drm_dev_unref(object)
  41. + drm_dev_put(object)
  42. )
  43. @r depends on report@
  44. expression object;
  45. position p;
  46. @@
  47. (
  48. drm_connector_unreference@p(object)
  49. |
  50. drm_connector_reference@p(object)
  51. |
  52. drm_framebuffer_unreference@p(object)
  53. |
  54. drm_framebuffer_reference@p(object)
  55. |
  56. drm_gem_object_unreference@p(object)
  57. |
  58. drm_gem_object_reference@p(object)
  59. |
  60. __drm_gem_object_unreference(object)
  61. |
  62. drm_gem_object_unreference_unlocked(object)
  63. |
  64. drm_dev_unref@p(object)
  65. )
  66. @script:python depends on report@
  67. object << r.object;
  68. p << r.p;
  69. @@
  70. msg="WARNING: use get/put helpers to reference and dereference %s" % (object)
  71. coccilib.report.print_report(p[0], msg)