diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/posix/bitmap.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/posix/bitmap.c | 57 |
1 files changed, 2 insertions, 55 deletions
diff --git a/drivers/gpu/nvgpu/common/posix/bitmap.c b/drivers/gpu/nvgpu/common/posix/bitmap.c index 51361777..b45838df 100644 --- a/drivers/gpu/nvgpu/common/posix/bitmap.c +++ b/drivers/gpu/nvgpu/common/posix/bitmap.c | |||
@@ -31,65 +31,12 @@ | |||
31 | 31 | ||
32 | unsigned long __nvgpu_posix_fls(unsigned long word) | 32 | unsigned long __nvgpu_posix_fls(unsigned long word) |
33 | { | 33 | { |
34 | int num = BITS_PER_LONG - 1; | 34 | return __builtin_clzl(word); |
35 | |||
36 | #if BITS_PER_LONG == 64 | ||
37 | if (!(word & (~0ul << 32))) { | ||
38 | num -= 32; | ||
39 | word <<= 32; | ||
40 | } | ||
41 | #endif | ||
42 | if (!(word & (~0ul << (BITS_PER_LONG-16)))) { | ||
43 | num -= 16; | ||
44 | word <<= 16; | ||
45 | } | ||
46 | if (!(word & (~0ul << (BITS_PER_LONG-8)))) { | ||
47 | num -= 8; | ||
48 | word <<= 8; | ||
49 | } | ||
50 | if (!(word & (~0ul << (BITS_PER_LONG-4)))) { | ||
51 | num -= 4; | ||
52 | word <<= 4; | ||
53 | } | ||
54 | if (!(word & (~0ul << (BITS_PER_LONG-2)))) { | ||
55 | num -= 2; | ||
56 | word <<= 2; | ||
57 | } | ||
58 | if (!(word & (~0ul << (BITS_PER_LONG-1)))) | ||
59 | num -= 1; | ||
60 | return num; | ||
61 | } | 35 | } |
62 | 36 | ||
63 | unsigned long __nvgpu_posix_ffs(unsigned long word) | 37 | unsigned long __nvgpu_posix_ffs(unsigned long word) |
64 | { | 38 | { |
65 | int num = 0; | 39 | return __builtin_ffsl(word); |
66 | |||
67 | #if BITS_PER_LONG == 64 | ||
68 | if ((word & 0xffffffff) == 0) { | ||
69 | num += 32; | ||
70 | word >>= 32; | ||
71 | } | ||
72 | #endif | ||
73 | if ((word & 0xffff) == 0) { | ||
74 | num += 16; | ||
75 | word >>= 16; | ||
76 | } | ||
77 | if ((word & 0xff) == 0) { | ||
78 | num += 8; | ||
79 | word >>= 8; | ||
80 | } | ||
81 | if ((word & 0xf) == 0) { | ||
82 | num += 4; | ||
83 | word >>= 4; | ||
84 | } | ||
85 | if ((word & 0x3) == 0) { | ||
86 | num += 2; | ||
87 | word >>= 2; | ||
88 | } | ||
89 | if ((word & 0x1) == 0) | ||
90 | num += 1; | ||
91 | |||
92 | return num; | ||
93 | } | 40 | } |
94 | 41 | ||
95 | static unsigned long __find_next_bit(const unsigned long *addr, | 42 | static unsigned long __find_next_bit(const unsigned long *addr, |