diff --git a/include/linux/log2.h b/include/linux/log2.h index 389043a..d9913f0 100644 --- a/include/linux/log2.h +++ b/include/linux/log2.h @@ -54,6 +54,15 @@ return (n != 0 && ((n & (n - 1)) == 0)); } +/* + * round up to nearest power of two + */ +static inline __attribute__((const)) +unsigned long __roundup_pow_of_two(unsigned long n) +{ + return 1UL << fls(n - 1); +} + /** * ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value * @n - parameter