diff options
Diffstat (limited to 'include/linux/bitops.h')
-rw-r--r-- | include/linux/bitops.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index cb3c3ef50f50..38c2fb7ebe09 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h | |||
@@ -84,6 +84,16 @@ static __inline__ int get_bitmask_order(unsigned int count) | |||
84 | return order; /* We could be slightly more clever with -1 here... */ | 84 | return order; /* We could be slightly more clever with -1 here... */ |
85 | } | 85 | } |
86 | 86 | ||
87 | static __inline__ int get_count_order(unsigned int count) | ||
88 | { | ||
89 | int order; | ||
90 | |||
91 | order = fls(count) - 1; | ||
92 | if (count & (count - 1)) | ||
93 | order++; | ||
94 | return order; | ||
95 | } | ||
96 | |||
87 | /* | 97 | /* |
88 | * hweightN: returns the hamming weight (i.e. the number | 98 | * hweightN: returns the hamming weight (i.e. the number |
89 | * of bits set) of a N-bit word | 99 | * of bits set) of a N-bit word |