@@ -15,6 +15,5 @@ void *alloc_pages(unsigned int order);
void free_page(void *page);
void free_pages(void *mem, size_t size);
void free_pages_by_order(void *mem, unsigned int order);
-unsigned int get_order(size_t size);
#endif
@@ -74,4 +74,14 @@ static inline unsigned long fls(unsigned long word)
}
#endif
+static inline bool is_power_of_2(unsigned long n)
+{
+ return n && !(n & (n - 1));
+}
+
+static inline unsigned int get_order(size_t size)
+{
+ return size ? fls(size) + !is_power_of_2(size) : 0;
+}
+
#endif
@@ -147,11 +147,6 @@ do { \
} \
} while (0)
-static inline bool is_power_of_2(unsigned long n)
-{
- return n && !(n & (n - 1));
-}
-
/*
* One byte per bit, a ' between each group of 4 bits, and a null terminator.
*/
@@ -1,4 +1,5 @@
#include "alloc.h"
+#include "bitops.h"
#include "asm/page.h"
#include "bitops.h"
@@ -175,8 +175,3 @@ void page_alloc_ops_enable(void)
{
alloc_ops = &page_alloc_ops;
}
-
-unsigned int get_order(size_t size)
-{
- return is_power_of_2(size) ? fls(size) : fls(size) + 1;
-}
The functions get_order and is_power_of_2 are simple and should probably be in a header, like similar simple functions in bitops.h Since they concern bit manipulation, the logical place for them is in bitops.h Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com> --- lib/alloc_page.h | 1 - lib/bitops.h | 10 ++++++++++ lib/libcflat.h | 5 ----- lib/alloc.c | 1 + lib/alloc_page.c | 5 ----- 5 files changed, 11 insertions(+), 11 deletions(-)