diff options
Diffstat (limited to 'include/linux/log2.h')
-rw-r--r-- | include/linux/log2.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/log2.h b/include/linux/log2.h index c8cf5e8ef171..25b808631cd9 100644 --- a/include/linux/log2.h +++ b/include/linux/log2.h | |||
@@ -190,4 +190,20 @@ unsigned long __rounddown_pow_of_two(unsigned long n) | |||
190 | __rounddown_pow_of_two(n) \ | 190 | __rounddown_pow_of_two(n) \ |
191 | ) | 191 | ) |
192 | 192 | ||
193 | /** | ||
194 | * order_base_2 - calculate the (rounded up) base 2 order of the argument | ||
195 | * @n: parameter | ||
196 | * | ||
197 | * The first few values calculated by this routine: | ||
198 | * ob2(0) = 0 | ||
199 | * ob2(1) = 0 | ||
200 | * ob2(2) = 1 | ||
201 | * ob2(3) = 2 | ||
202 | * ob2(4) = 2 | ||
203 | * ob2(5) = 3 | ||
204 | * ... and so on. | ||
205 | */ | ||
206 | |||
207 | #define order_base_2(n) ilog2(roundup_pow_of_two(n)) | ||
208 | |||
193 | #endif /* _LINUX_LOG2_H */ | 209 | #endif /* _LINUX_LOG2_H */ |