summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/nvgpu/common/posix/bitmap.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/gpu/nvgpu/common/posix/bitmap.c b/drivers/gpu/nvgpu/common/posix/bitmap.c
index b45838df..f25f6e64 100644
--- a/drivers/gpu/nvgpu/common/posix/bitmap.c
+++ b/drivers/gpu/nvgpu/common/posix/bitmap.c
@@ -29,14 +29,15 @@
29#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) 29#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
30#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) 30#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
31 31
32unsigned long __nvgpu_posix_fls(unsigned long word) 32unsigned long __nvgpu_posix_ffs(unsigned long word)
33{ 33{
34 return __builtin_clzl(word); 34 return (__builtin_ffsl(word) - 1) &
35 ((sizeof(unsigned long) * 8UL) - 1UL);
35} 36}
36 37
37unsigned long __nvgpu_posix_ffs(unsigned long word) 38unsigned long __nvgpu_posix_fls(unsigned long word)
38{ 39{
39 return __builtin_ffsl(word); 40 return ((sizeof(unsigned long) * 8UL) - 1UL) - __builtin_clzl(word);
40} 41}
41 42
42static unsigned long __find_next_bit(const unsigned long *addr, 43static unsigned long __find_next_bit(const unsigned long *addr,