@@ -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;
-}