aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm/drm_framebuffer.h
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2017-02-28 09:46:40 -0500
committerThierry Reding <treding@nvidia.com>2017-02-28 10:15:03 -0500
commita4a69da06bc11a937a6e417938b1bb698ee1fa46 (patch)
treef27062e64385f44ddddabc08b8d3f98cc2700446 /include/drm/drm_framebuffer.h
parentad09360750afa18a0a0ce0253d6ea6033abc22e7 (diff)
drm: Introduce drm_framebuffer_{get,put}()
For consistency with other reference counting APIs in the kernel, add drm_framebuffer_get() and drm_framebuffer_put() to reference count DRM framebuffers. 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. The existing semantic patch for the DRM subsystem-wide conversion is extended to account for these new helpers. Reviewed-by: Sean Paul <seanpaul@chromium.org> Acked-by: Christian König <christian.koenig@amd.com> Signed-off-by: Thierry Reding <treding@nvidia.com> Link: http://patchwork.freedesktop.org/patch/msgid/20170228144643.5668-5-thierry.reding@gmail.com
Diffstat (limited to 'include/drm/drm_framebuffer.h')
-rw-r--r--include/drm/drm_framebuffer.h49
1 files changed, 37 insertions, 12 deletions
diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h
index 04c77eee9c20..45410ba0d4f7 100644
--- a/include/drm/drm_framebuffer.h
+++ b/include/drm/drm_framebuffer.h
@@ -101,8 +101,8 @@ struct drm_framebuffer_funcs {
101 * cleanup (like releasing the reference(s) on the backing GEM bo(s)) 101 * cleanup (like releasing the reference(s) on the backing GEM bo(s))
102 * should be deferred. In cases like this, the driver would like to 102 * should be deferred. In cases like this, the driver would like to
103 * hold a ref to the fb even though it has already been removed from 103 * hold a ref to the fb even though it has already been removed from
104 * userspace perspective. See drm_framebuffer_reference() and 104 * userspace perspective. See drm_framebuffer_get() and
105 * drm_framebuffer_unreference(). 105 * drm_framebuffer_put().
106 * 106 *
107 * The refcount is stored inside the mode object @base. 107 * The refcount is stored inside the mode object @base.
108 */ 108 */
@@ -204,25 +204,50 @@ void drm_framebuffer_cleanup(struct drm_framebuffer *fb);
204void drm_framebuffer_unregister_private(struct drm_framebuffer *fb); 204void drm_framebuffer_unregister_private(struct drm_framebuffer *fb);
205 205
206/** 206/**
207 * drm_framebuffer_reference - incr the fb refcnt 207 * drm_framebuffer_get - acquire a framebuffer reference
208 * @fb: framebuffer 208 * @fb: DRM framebuffer
209 *
210 * This function increments the framebuffer's reference count.
211 */
212static inline void drm_framebuffer_get(struct drm_framebuffer *fb)
213{
214 drm_mode_object_get(&fb->base);
215}
216
217/**
218 * drm_framebuffer_put - release a framebuffer reference
219 * @fb: DRM framebuffer
220 *
221 * This function decrements the framebuffer's reference count and frees the
222 * framebuffer if the reference count drops to zero.
223 */
224static inline void drm_framebuffer_put(struct drm_framebuffer *fb)
225{
226 drm_mode_object_put(&fb->base);
227}
228
229/**
230 * drm_framebuffer_reference - acquire a framebuffer reference
231 * @fb: DRM framebuffer
209 * 232 *
210 * This functions increments the fb's refcount. 233 * This is a compatibility alias for drm_framebuffer_get() and should not be
234 * used by new code.
211 */ 235 */
212static inline void drm_framebuffer_reference(struct drm_framebuffer *fb) 236static inline void drm_framebuffer_reference(struct drm_framebuffer *fb)
213{ 237{
214 drm_mode_object_reference(&fb->base); 238 drm_framebuffer_get(fb);
215} 239}
216 240
217/** 241/**
218 * drm_framebuffer_unreference - unref a framebuffer 242 * drm_framebuffer_unreference - release a framebuffer reference
219 * @fb: framebuffer to unref 243 * @fb: DRM framebuffer
220 * 244 *
221 * This functions decrements the fb's refcount and frees it if it drops to zero. 245 * This is a compatibility alias for drm_framebuffer_put() and should not be
246 * used by new code.
222 */ 247 */
223static inline void drm_framebuffer_unreference(struct drm_framebuffer *fb) 248static inline void drm_framebuffer_unreference(struct drm_framebuffer *fb)
224{ 249{
225 drm_mode_object_unreference(&fb->base); 250 drm_framebuffer_put(fb);
226} 251}
227 252
228/** 253/**
@@ -248,9 +273,9 @@ static inline void drm_framebuffer_assign(struct drm_framebuffer **p,
248 struct drm_framebuffer *fb) 273 struct drm_framebuffer *fb)
249{ 274{
250 if (fb) 275 if (fb)
251 drm_framebuffer_reference(fb); 276 drm_framebuffer_get(fb);
252 if (*p) 277 if (*p)
253 drm_framebuffer_unreference(*p); 278 drm_framebuffer_put(*p);
254 *p = fb; 279 *p = fb;
255} 280}
256 281