Commit 5d98d0bc authored by Christian König's avatar Christian König Committed by 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: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarChunming Zhou <david1.zhou@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 5756b155
......@@ -57,14 +57,14 @@ static struct attribute ttm_bo_count = {
static inline int ttm_mem_type_from_place(const struct ttm_place *place,
uint32_t *mem_type)
{
int i;
int pos;
for (i = 0; i <= TTM_PL_PRIV5; i++)
if (place->flags & (1 << i)) {
*mem_type = i;
return 0;
}
return -EINVAL;
pos = ffs(place->flags & TTM_PL_MASK_MEM);
if (unlikely(!pos))
return -EINVAL;
*mem_type = pos - 1;
return 0;
}
static void ttm_mem_type_debug(struct ttm_bo_device *bdev, int mem_type)
......
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