Commit cb56acea authored by Dave Airlie's avatar Dave Airlie Committed by Alex Deucher

amdgpu/dc: convert dc_sink to kref.

Refcounts use krefs.
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent bfe0feb1
...@@ -63,19 +63,19 @@ static bool construct(struct dc_sink *sink, const struct dc_sink_init_data *init ...@@ -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) void dc_sink_retain(struct dc_sink *sink)
{ {
ASSERT(atomic_read(&sink->ref_count) > 0); kref_get(&sink->refcount);
atomic_inc(&sink->ref_count);
} }
void dc_sink_release(struct dc_sink *sink) static void dc_sink_free(struct kref *kref)
{ {
ASSERT(atomic_read(&sink->ref_count) > 0); struct dc_sink *sink = container_of(kref, struct dc_sink, refcount);
atomic_dec(&sink->ref_count); destruct(sink);
kfree(sink);
}
if (atomic_read(&sink->ref_count) == 0) { void dc_sink_release(struct dc_sink *sink)
destruct(sink); {
kfree(sink); kref_put(&sink->refcount, dc_sink_free);
}
} }
struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params) 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) ...@@ -88,7 +88,7 @@ struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params)
if (false == construct(sink, init_params)) if (false == construct(sink, init_params))
goto construct_fail; goto construct_fail;
atomic_inc(&sink->ref_count); kref_init(&sink->refcount);
return sink; return sink;
......
...@@ -971,7 +971,7 @@ struct dc_sink { ...@@ -971,7 +971,7 @@ struct dc_sink {
struct dc_context *ctx; struct dc_context *ctx;
/* private to dc_sink.c */ /* private to dc_sink.c */
atomic_t ref_count; struct kref refcount;
}; };
void dc_sink_retain(struct dc_sink *sink); void dc_sink_retain(struct dc_sink *sink);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment