diff options
author | 2017-10-03 12:38:58 +1000 | |
---|---|---|
committer | 2017-10-06 13:09:10 -0400 | |
commit | 5c58ab0bd61b5c8538721f4200475c0af0e33efe (patch) | |
tree | 32c4f16006f9293005dfc63c16ce8d39d411e575 /drivers/gpu/drm/amd/display/dc/core/dc_surface.c | |
parent | amdgpu/dc: convert dc_transfer to use a kref. (diff) | |
download | linux-dev-5c58ab0bd61b5c8538721f4200475c0af0e33efe.tar.xz linux-dev-5c58ab0bd61b5c8538721f4200475c0af0e33efe.zip |
amdgpu/dc: convert dc_gamma to kref reference counting.
Rolling your own reference counting 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.c | 19 |
1 files changed, 9 insertions, 10 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 c2168dfacc8d..0950075b6c54 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_surface.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_surface.c @@ -129,18 +129,18 @@ void dc_plane_state_release(struct dc_plane_state *plane_state) void dc_gamma_retain(struct dc_gamma *gamma) { - ASSERT(atomic_read(&gamma->ref_count) > 0); - atomic_inc(&gamma->ref_count); + kref_get(&gamma->refcount); } -void dc_gamma_release(struct dc_gamma **gamma) +static void dc_gamma_free(struct kref *kref) { - ASSERT(atomic_read(&(*gamma)->ref_count) > 0); - atomic_dec(&(*gamma)->ref_count); - - if (atomic_read(&(*gamma)->ref_count) == 0) - kfree((*gamma)); + struct dc_gamma *gamma = container_of(kref, struct dc_gamma, refcount); + kfree(gamma); +} +void dc_gamma_release(struct dc_gamma **gamma) +{ + kref_put(&(*gamma)->refcount, dc_gamma_free); *gamma = NULL; } @@ -151,8 +151,7 @@ struct dc_gamma *dc_create_gamma() if (gamma == NULL) goto alloc_fail; - atomic_inc(&gamma->ref_count); - + kref_init(&gamma->refcount); return gamma; alloc_fail: |