diff options
author | Dave Airlie <airlied@redhat.com> | 2017-10-03 12:39:01 +1000 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-10-06 13:10:08 -0400 |
commit | cb56aceabd36ef42bc7e081c43dc55ef57efba7a (patch) | |
tree | acd03fc81c47b24ef2b2395d07837707c829d375 | |
parent | bfe0feb143151cce76411bb211c3eec0f6cff7ba (diff) | |
download | linux-stable-cb56aceabd36ef42bc7e081c43dc55ef57efba7a.tar.gz linux-stable-cb56aceabd36ef42bc7e081c43dc55ef57efba7a.tar.bz2 linux-stable-cb56aceabd36ef42bc7e081c43dc55ef57efba7a.zip |
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>
-rw-r--r-- | drivers/gpu/drm/amd/display/dc/core/dc_sink.c | 20 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/display/dc/dc.h | 2 |
2 files changed, 11 insertions, 11 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; diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index 97f6f34f3d22..4ff543826476 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h @@ -971,7 +971,7 @@ struct dc_sink { struct dc_context *ctx; /* private to dc_sink.c */ - atomic_t ref_count; + struct kref refcount; }; void dc_sink_retain(struct dc_sink *sink); |