提交 5d98d0bc 编写于 作者: C Christian König 提交者: Alex Deucher

drm/ttm: use ffs in ttm_mem_type_from_place

A bit pointless to search for the first bit set manually.
Signed-off-by: NChristian König <christian.koenig@amd.com>
Reviewed-by: NAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: NChunming Zhou <david1.zhou@amd.com>
Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
上级 5756b155
...@@ -57,14 +57,14 @@ static struct attribute ttm_bo_count = { ...@@ -57,14 +57,14 @@ static struct attribute ttm_bo_count = {
static inline int ttm_mem_type_from_place(const struct ttm_place *place, static inline int ttm_mem_type_from_place(const struct ttm_place *place,
uint32_t *mem_type) uint32_t *mem_type)
{ {
int i; int pos;
for (i = 0; i <= TTM_PL_PRIV5; i++) pos = ffs(place->flags & TTM_PL_MASK_MEM);
if (place->flags & (1 << i)) { if (unlikely(!pos))
*mem_type = i; return -EINVAL;
return 0;
} *mem_type = pos - 1;
return -EINVAL; return 0;
} }
static void ttm_mem_type_debug(struct ttm_bo_device *bdev, int mem_type) static void ttm_mem_type_debug(struct ttm_bo_device *bdev, int mem_type)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册