summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2017-10-03 12:39:01 +1000
committerAlex Deucher <alexander.deucher@amd.com>2017-10-06 13:10:08 -0400
commitcb56aceabd36ef42bc7e081c43dc55ef57efba7a (patch)
treeacd03fc81c47b24ef2b2395d07837707c829d375 /drivers/gpu/drm/amd/display/dc/core/dc_sink.c
parentbfe0feb143151cce76411bb211c3eec0f6cff7ba (diff)
amdgpu/dc: convert dc_sink to kref.
Refcounts use krefs. 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_sink.c')
-rw-r--r--drivers/gpu/drm/amd/display/dc/core/dc_sink.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
index 3d620d3d0672..25fae38409ab 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
@@ -63,19 +63,19 @@ static bool construct(struct dc_sink *sink, const struct dc_sink_init_data *init
void dc_sink_retain(struct dc_sink *sink)
{
- ASSERT(atomic_read(&sink->ref_count) > 0);
- atomic_inc(&sink->ref_count);
+ kref_get(&sink->refcount);
}
-void dc_sink_release(struct dc_sink *sink)
+static void dc_sink_free(struct kref *kref)
{
- ASSERT(atomic_read(&sink->ref_count) > 0);
- atomic_dec(&sink->ref_count);
+ struct dc_sink *sink = container_of(kref, struct dc_sink, refcount);
+ destruct(sink);
+ kfree(sink);
+}
- if (atomic_read(&sink->ref_count) == 0) {
- destruct(sink);
- kfree(sink);
- }
+void dc_sink_release(struct dc_sink *sink)
+{
+ kref_put(&sink->refcount, dc_sink_free);
}
struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params)
@@ -88,7 +88,7 @@ struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params)
if (false == construct(sink, init_params))
goto construct_fail;
- atomic_inc(&sink->ref_count);
+ kref_init(&sink->refcount);
return sink;