diff options
author | Christian König <christian.koenig@amd.com> | 2016-09-12 07:16:16 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-09-14 15:10:41 -0400 |
commit | 5d98d0bcff64c9a76d21da9648881e14ed26fff6 (patch) | |
tree | 162704703fc64cd4c98c87229cd7e6dc0207056b /drivers | |
parent | 5756b1558eabdfb087aa9896250c6decd12bf872 (diff) |
drm/ttm: use ffs in ttm_mem_type_from_place
A bit pointless to search for the first bit set manually.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_bo.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index c2a30bdc8a01..fc6217dfe401 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c | |||
@@ -57,14 +57,14 @@ static struct attribute ttm_bo_count = { | |||
57 | static inline int ttm_mem_type_from_place(const struct ttm_place *place, | 57 | static inline int ttm_mem_type_from_place(const struct ttm_place *place, |
58 | uint32_t *mem_type) | 58 | uint32_t *mem_type) |
59 | { | 59 | { |
60 | int i; | 60 | int pos; |
61 | 61 | ||
62 | for (i = 0; i <= TTM_PL_PRIV5; i++) | 62 | pos = ffs(place->flags & TTM_PL_MASK_MEM); |
63 | if (place->flags & (1 << i)) { | 63 | if (unlikely(!pos)) |
64 | *mem_type = i; | 64 | return -EINVAL; |
65 | return 0; | 65 | |
66 | } | 66 | *mem_type = pos - 1; |
67 | return -EINVAL; | 67 | return 0; |
68 | } | 68 | } |
69 | 69 | ||
70 | static void ttm_mem_type_debug(struct ttm_bo_device *bdev, int mem_type) | 70 | static void ttm_mem_type_debug(struct ttm_bo_device *bdev, int mem_type) |