Commit e2721595 authored by Roger He's avatar Roger He Committed by Alex Deucher

drm/ttm: check the return value of register_shrinker

This fixes the build warning:
"ignoring return value of 'register_shrinker', declared with
attribute warn_unused_result [-Wunused-result]"
Signed-off-by: default avatarRoger He <Hongbo.He@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent c8c99b81
...@@ -477,12 +477,12 @@ ttm_pool_shrink_count(struct shrinker *shrink, struct shrink_control *sc) ...@@ -477,12 +477,12 @@ ttm_pool_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
return count; return count;
} }
static void ttm_pool_mm_shrink_init(struct ttm_pool_manager *manager) static int ttm_pool_mm_shrink_init(struct ttm_pool_manager *manager)
{ {
manager->mm_shrink.count_objects = ttm_pool_shrink_count; manager->mm_shrink.count_objects = ttm_pool_shrink_count;
manager->mm_shrink.scan_objects = ttm_pool_shrink_scan; manager->mm_shrink.scan_objects = ttm_pool_shrink_scan;
manager->mm_shrink.seeks = 1; manager->mm_shrink.seeks = 1;
register_shrinker(&manager->mm_shrink); return register_shrinker(&manager->mm_shrink);
} }
static void ttm_pool_mm_shrink_fini(struct ttm_pool_manager *manager) static void ttm_pool_mm_shrink_fini(struct ttm_pool_manager *manager)
...@@ -1032,15 +1032,18 @@ int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) ...@@ -1032,15 +1032,18 @@ int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages)
ret = kobject_init_and_add(&_manager->kobj, &ttm_pool_kobj_type, ret = kobject_init_and_add(&_manager->kobj, &ttm_pool_kobj_type,
&glob->kobj, "pool"); &glob->kobj, "pool");
if (unlikely(ret != 0)) { if (unlikely(ret != 0))
kobject_put(&_manager->kobj); goto error;
_manager = NULL;
return ret;
}
ttm_pool_mm_shrink_init(_manager);
ret = ttm_pool_mm_shrink_init(_manager);
if (unlikely(ret != 0))
goto error;
return 0; return 0;
error:
kobject_put(&_manager->kobj);
_manager = NULL;
return ret;
} }
void ttm_page_alloc_fini(void) void ttm_page_alloc_fini(void)
......
...@@ -1182,12 +1182,12 @@ ttm_dma_pool_shrink_count(struct shrinker *shrink, struct shrink_control *sc) ...@@ -1182,12 +1182,12 @@ ttm_dma_pool_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
return count; return count;
} }
static void ttm_dma_pool_mm_shrink_init(struct ttm_pool_manager *manager) static int ttm_dma_pool_mm_shrink_init(struct ttm_pool_manager *manager)
{ {
manager->mm_shrink.count_objects = ttm_dma_pool_shrink_count; manager->mm_shrink.count_objects = ttm_dma_pool_shrink_count;
manager->mm_shrink.scan_objects = &ttm_dma_pool_shrink_scan; manager->mm_shrink.scan_objects = &ttm_dma_pool_shrink_scan;
manager->mm_shrink.seeks = 1; manager->mm_shrink.seeks = 1;
register_shrinker(&manager->mm_shrink); return register_shrinker(&manager->mm_shrink);
} }
static void ttm_dma_pool_mm_shrink_fini(struct ttm_pool_manager *manager) static void ttm_dma_pool_mm_shrink_fini(struct ttm_pool_manager *manager)
...@@ -1197,7 +1197,7 @@ static void ttm_dma_pool_mm_shrink_fini(struct ttm_pool_manager *manager) ...@@ -1197,7 +1197,7 @@ static void ttm_dma_pool_mm_shrink_fini(struct ttm_pool_manager *manager)
int ttm_dma_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) int ttm_dma_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages)
{ {
int ret = -ENOMEM; int ret;
WARN_ON(_manager); WARN_ON(_manager);
...@@ -1205,7 +1205,7 @@ int ttm_dma_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) ...@@ -1205,7 +1205,7 @@ int ttm_dma_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages)
_manager = kzalloc(sizeof(*_manager), GFP_KERNEL); _manager = kzalloc(sizeof(*_manager), GFP_KERNEL);
if (!_manager) if (!_manager)
goto err; return -ENOMEM;
mutex_init(&_manager->lock); mutex_init(&_manager->lock);
INIT_LIST_HEAD(&_manager->pools); INIT_LIST_HEAD(&_manager->pools);
...@@ -1217,13 +1217,17 @@ int ttm_dma_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) ...@@ -1217,13 +1217,17 @@ int ttm_dma_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages)
/* This takes care of auto-freeing the _manager */ /* This takes care of auto-freeing the _manager */
ret = kobject_init_and_add(&_manager->kobj, &ttm_pool_kobj_type, ret = kobject_init_and_add(&_manager->kobj, &ttm_pool_kobj_type,
&glob->kobj, "dma_pool"); &glob->kobj, "dma_pool");
if (unlikely(ret != 0)) { if (unlikely(ret != 0))
kobject_put(&_manager->kobj); goto error;
goto err;
} ret = ttm_dma_pool_mm_shrink_init(_manager);
ttm_dma_pool_mm_shrink_init(_manager); if (unlikely(ret != 0))
goto error;
return 0; return 0;
err:
error:
kobject_put(&_manager->kobj);
_manager = NULL;
return ret; return ret;
} }
......
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