diff options
Diffstat (limited to 'drivers/gpu/nvgpu/os/posix/bitmap.c')
-rw-r--r-- | drivers/gpu/nvgpu/os/posix/bitmap.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/os/posix/bitmap.c b/drivers/gpu/nvgpu/os/posix/bitmap.c index f25f6e64..99ba62c3 100644 --- a/drivers/gpu/nvgpu/os/posix/bitmap.c +++ b/drivers/gpu/nvgpu/os/posix/bitmap.c | |||
@@ -37,7 +37,18 @@ unsigned long __nvgpu_posix_ffs(unsigned long word) | |||
37 | 37 | ||
38 | unsigned long __nvgpu_posix_fls(unsigned long word) | 38 | unsigned long __nvgpu_posix_fls(unsigned long word) |
39 | { | 39 | { |
40 | return ((sizeof(unsigned long) * 8UL) - 1UL) - __builtin_clzl(word); | 40 | unsigned long ret; |
41 | |||
42 | if (word == 0UL) { | ||
43 | /* __builtin_clzl() below is undefined for 0, so we have | ||
44 | * to handle that as a special case. | ||
45 | */ | ||
46 | ret = 0UL; | ||
47 | } else { | ||
48 | ret = (sizeof(unsigned long) * 8UL) - __builtin_clzl(word); | ||
49 | } | ||
50 | |||
51 | return ret; | ||
41 | } | 52 | } |
42 | 53 | ||
43 | static unsigned long __find_next_bit(const unsigned long *addr, | 54 | static unsigned long __find_next_bit(const unsigned long *addr, |