summaryrefslogtreecommitdiffstats
path: root/include/linux/log2.h
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@free-electrons.com>2013-02-26 17:51:13 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-02-27 08:59:34 +0100
commit4f105dd77466b8504a0b3e78d7ffd6aa6ecd9079 (patch)
tree97125722552a576b4ebe7413a70fb2ff660b12ca /include/linux/log2.h
parent91786b5bc8e8b8e35a0d8dadfa216163f7f5ac92 (diff)
downloadbarebox-4f105dd77466b8504a0b3e78d7ffd6aa6ecd9079.tar.gz
barebox-4f105dd77466b8504a0b3e78d7ffd6aa6ecd9079.tar.xz
log2: Fix declaration of __roundup_pow_of_two
The roundup_pow_of_two function is making use of __roundup_pow_of_two when the call to __builtin_constant_p fails, which is not implemented in barebox. Copied the code from Linux log2.h header. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/linux/log2.h')
-rw-r--r--include/linux/log2.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/log2.h b/include/linux/log2.h
index 389043a93c..d9913f06bd 100644
--- a/include/linux/log2.h
+++ b/include/linux/log2.h
@@ -54,6 +54,15 @@ bool is_power_of_2(unsigned long n)
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