aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/display/dc/core/dc_surface.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2017-10-03 12:38:57 +1000
committerAlex Deucher <alexander.deucher@amd.com>2017-10-06 13:08:55 -0400
commit93052132568aedb5eda04deae51d6034738a4800 (patch)
tree1687927f5b0cb97f0a6439893fba65ad1eb53cfc /drivers/gpu/drm/amd/display/dc/core/dc_surface.c
parentamdgpu/dc: kill a bunch of dead code. (diff)
downloadlinux-dev-93052132568aedb5eda04deae51d6034738a4800.tar.xz
linux-dev-93052132568aedb5eda04deae51d6034738a4800.zip
amdgpu/dc: convert dc_transfer to use a kref.
Rolling your own atomic ref counts is frowned upon. Signed-off-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Harry Wentland <harry.wentland@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/display/dc/core/dc_surface.c')
-rw-r--r--drivers/gpu/drm/amd/display/dc/core/dc_surface.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_surface.c b/drivers/gpu/drm/amd/display/dc/core/dc_surface.c
index ff07105bfd99..c2168dfacc8d 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_surface.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_surface.c
@@ -161,17 +161,18 @@ alloc_fail:
void dc_transfer_func_retain(struct dc_transfer_func *tf)
{
- ASSERT(atomic_read(&tf->ref_count) > 0);
- atomic_inc(&tf->ref_count);
+ kref_get(&tf->refcount);
}
-void dc_transfer_func_release(struct dc_transfer_func *tf)
+static void dc_transfer_func_free(struct kref *kref)
{
- ASSERT(atomic_read(&tf->ref_count) > 0);
- atomic_dec(&tf->ref_count);
+ struct dc_transfer_func *tf = container_of(kref, struct dc_transfer_func, refcount);
+ kfree(tf);
+}
- if (atomic_read(&tf->ref_count) == 0)
- kfree(tf);
+void dc_transfer_func_release(struct dc_transfer_func *tf)
+{
+ kref_put(&tf->refcount, dc_transfer_func_free);
}
struct dc_transfer_func *dc_create_transfer_func()
@@ -181,7 +182,7 @@ struct dc_transfer_func *dc_create_transfer_func()
if (tf == NULL)
goto alloc_fail;
- atomic_inc(&tf->ref_count);
+ kref_init(&tf->refcount);
return tf;