summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm/ttm_bo.c
diff options
context:
space:
mode:
authorTom St Denis <tom.stdenis@amd.com>2018-01-24 20:26:41 +0100
committerAlex Deucher <alexander.deucher@amd.com>2018-02-19 20:18:56 +0100
commit420457acfb3060990bfca2af3d63730c26739de0 (patch)
treeff9a0383f07c4bedd56e2700648c888149fbbe02 /drivers/gpu/drm/ttm/ttm_bo.c
parentdrm/ttm: Fix coding style in ttm_bo.c (diff)
downloadlinux-420457acfb3060990bfca2af3d63730c26739de0.tar.xz
linux-420457acfb3060990bfca2af3d63730c26739de0.zip
drm/ttm: Add a default BO destructor to simplify code (v2)
(v2): Remove stray ; noticed by Felix Signed-off-by: Tom St Denis <tom.stdenis@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_bo.c')
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 8cf89da7030d..d90b1cf10b27 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -49,6 +49,12 @@ static struct attribute ttm_bo_count = {
.mode = S_IRUGO
};
+/* default destructor */
+static void ttm_bo_default_destroy(struct ttm_buffer_object *bo)
+{
+ kfree(bo);
+}
+
static inline int ttm_mem_type_from_place(const struct ttm_place *place,
uint32_t *mem_type)
{
@@ -147,10 +153,7 @@ static void ttm_bo_release_list(struct kref *list_kref)
dma_fence_put(bo->moving);
reservation_object_fini(&bo->ttm_resv);
mutex_destroy(&bo->wu_mutex);
- if (bo->destroy)
- bo->destroy(bo);
- else
- kfree(bo);
+ bo->destroy(bo);
ttm_mem_global_free(bdev->glob->mem_glob, acc_size);
}
@@ -1176,7 +1179,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev,
ttm_mem_global_free(mem_glob, acc_size);
return -EINVAL;
}
- bo->destroy = destroy;
+ bo->destroy = destroy ? destroy : ttm_bo_default_destroy;
kref_init(&bo->kref);
kref_init(&bo->list_kref);