diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/coccinelle/api/drm-get-put.cocci | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/scripts/coccinelle/api/drm-get-put.cocci b/scripts/coccinelle/api/drm-get-put.cocci new file mode 100644 index 000000000000..a3742447c981 --- /dev/null +++ b/scripts/coccinelle/api/drm-get-put.cocci | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | /// | ||
| 2 | /// Use drm_*_get() and drm_*_put() helpers instead of drm_*_reference() and | ||
| 3 | /// drm_*_unreference() helpers. | ||
| 4 | /// | ||
| 5 | // Confidence: High | ||
| 6 | // Copyright: (C) 2017 NVIDIA Corporation | ||
| 7 | // Options: --no-includes --include-headers | ||
| 8 | // | ||
| 9 | |||
| 10 | virtual patch | ||
| 11 | virtual report | ||
| 12 | |||
| 13 | @depends on patch@ | ||
| 14 | expression object; | ||
| 15 | @@ | ||
| 16 | |||
| 17 | ( | ||
| 18 | - drm_mode_object_reference(object) | ||
| 19 | + drm_mode_object_get(object) | ||
| 20 | | | ||
| 21 | - drm_mode_object_unreference(object) | ||
| 22 | + drm_mode_object_put(object) | ||
| 23 | ) | ||
| 24 | |||
| 25 | @r depends on report@ | ||
| 26 | expression object; | ||
| 27 | position p; | ||
| 28 | @@ | ||
| 29 | |||
| 30 | ( | ||
| 31 | drm_mode_object_unreference@p(object) | ||
| 32 | | | ||
| 33 | drm_mode_object_reference@p(object) | ||
| 34 | ) | ||
| 35 | |||
| 36 | @script:python depends on report@ | ||
| 37 | object << r.object; | ||
| 38 | p << r.p; | ||
| 39 | @@ | ||
| 40 | |||
| 41 | msg="WARNING: use get/put helpers to reference and dereference %s" % (object) | ||
| 42 | coccilib.report.print_report(p[0], msg) | ||
