From 020a218f95bd3ceff7dd1022ff7ebc0497bc7bf9 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Tue, 28 Feb 2017 15:46:38 +0100 Subject: drm: Introduce drm_mode_object_{get,put}() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Reviewed-by: Sean Paul Acked-by: Christian König Signed-off-by: Thierry Reding Link: http://patchwork.freedesktop.org/patch/msgid/20170228144643.5668-3-thierry.reding@gmail.com --- scripts/coccinelle/api/drm-get-put.cocci | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 scripts/coccinelle/api/drm-get-put.cocci (limited to 'scripts') 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 @@ +/// +/// Use drm_*_get() and drm_*_put() helpers instead of drm_*_reference() and +/// drm_*_unreference() helpers. +/// +// Confidence: High +// Copyright: (C) 2017 NVIDIA Corporation +// Options: --no-includes --include-headers +// + +virtual patch +virtual report + +@depends on patch@ +expression object; +@@ + +( +- drm_mode_object_reference(object) ++ drm_mode_object_get(object) +| +- drm_mode_object_unreference(object) ++ drm_mode_object_put(object) +) + +@r depends on report@ +expression object; +position p; +@@ + +( +drm_mode_object_unreference@p(object) +| +drm_mode_object_reference@p(object) +) + +@script:python depends on report@ +object << r.object; +p << r.p; +@@ + +msg="WARNING: use get/put helpers to reference and dereference %s" % (object) +coccilib.report.print_report(p[0], msg) -- cgit v1.2.3