diff options
author | Markus Pargmann <mpa@pengutronix.de> | 2015-12-08 10:39:25 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-12-10 08:49:52 +0100 |
commit | 6f42da2fc8aee833f4eeb5ad9cde6e7c79cd10d9 (patch) | |
tree | b5b822e4c8280acb197bf7d8b0a99236a6853b7d /include/linux/log2.h | |
parent | 2ab52a7b67c63b1619bba681afbfec965c3df702 (diff) | |
download | barebox-6f42da2fc8aee833f4eeb5ad9cde6e7c79cd10d9.tar.gz barebox-6f42da2fc8aee833f4eeb5ad9cde6e7c79cd10d9.tar.xz |
log2: Add missing __rounddown_pow_of_two()
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/linux/log2.h')
-rw-r--r-- | include/linux/log2.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/log2.h b/include/linux/log2.h index d9913f06bd..36519e3aa3 100644 --- a/include/linux/log2.h +++ b/include/linux/log2.h @@ -63,6 +63,15 @@ unsigned long __roundup_pow_of_two(unsigned long n) return 1UL << fls(n - 1); } +/* + * round down to nearest power of two + */ +static inline __attribute__((const)) +unsigned long __rounddown_pow_of_two(unsigned long n) +{ + return 1UL << (fls_long(n) - 1); +} + /** * ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value * @n - parameter |