amdgpu/dc: convert dc_stream_state to kref.

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>
This commit is contained in:
Dave Airlie 2017-10-03 12:39:00 +10:00 committed by Alex Deucher
parent 4d090f0fae
commit bfe0feb143
2 changed files with 12 additions and 12 deletions

View File

@ -118,20 +118,21 @@ static void destruct(struct dc_stream_state *stream)
void dc_stream_retain(struct dc_stream_state *stream) void dc_stream_retain(struct dc_stream_state *stream)
{ {
ASSERT(atomic_read(&stream->ref_count) > 0); kref_get(&stream->refcount);
atomic_inc(&stream->ref_count); }
static void dc_stream_free(struct kref *kref)
{
struct dc_stream_state *stream = container_of(kref, struct dc_stream_state, refcount);
destruct(stream);
kfree(stream);
} }
void dc_stream_release(struct dc_stream_state *stream) void dc_stream_release(struct dc_stream_state *stream)
{ {
if (stream != NULL) { if (stream != NULL) {
ASSERT(atomic_read(&stream->ref_count) > 0); kref_put(&stream->refcount, dc_stream_free);
atomic_dec(&stream->ref_count);
if (atomic_read(&stream->ref_count) == 0) {
destruct(stream);
kfree(stream);
}
} }
} }
@ -149,10 +150,9 @@ struct dc_stream_state *dc_create_stream_for_sink(
construct(stream, sink); construct(stream, sink);
atomic_inc(&stream->ref_count); kref_init(&stream->refcount);
return stream; return stream;
} }
struct dc_stream_status *dc_stream_get_status( struct dc_stream_status *dc_stream_get_status(

View File

@ -558,7 +558,7 @@ struct dc_stream_state {
struct dc_stream_status status; struct dc_stream_status status;
/* from stream struct */ /* from stream struct */
atomic_t ref_count; struct kref refcount;
}; };
struct dc_stream_update { struct dc_stream_update {