summaryrefslogtreecommitdiffstats
path: root/include/linux/log2.h
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-01-11 13:11:07 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2016-01-11 13:11:07 +0100
commit70ef1cef5c1a03a4b130f3916d47c3076880b5d6 (patch)
treecc0faaf8e07a08600f9b958850d7f7669c0ae02d /include/linux/log2.h
parente64f16cf34175d9e662edfaa02bc7895c1b50b96 (diff)
parent9e617362fc300d31a4e7f6c5b72781b58c03f78a (diff)
downloadbarebox-70ef1cef5c1a03a4b130f3916d47c3076880b5d6.tar.gz
barebox-70ef1cef5c1a03a4b130f3916d47c3076880b5d6.tar.xz
Merge branch 'for-next/pstore'
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 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