History

drm: Introduce drm_mode_object_{get,put}()

For consistency with other reference counting APIs in the kernel, add drm_mode_object_get() and drm_mode_object_put() to reference count DRM mode objects. Compatibility aliases are added to keep existing code working. To help speed up the transition, all the instances of the old functions in the DRM core are already replaced in this commit. A semantic patch is provided that can be used to convert all drivers to the new helpers.

Thierry Reding committed 9 years ago

Commit 020a2181 parent 2135ea75 files · +95 −29Browse files

Showing the changes to scripts (1 of 5 files). Show all

Unified · Split

scripts/coccinelle/api/drm-get-put.cocci+42−0
@@ -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)