diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-10-27 18:14:56 +0100 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-10-28 13:54:41 +0100 |
commit | 7dc50ec7283391dd7a29a80e2a0fb76731a6a7c7 (patch) | |
tree | cfce6e8adf5c4a50ed04f390a7acf8f4d7d8b5df /arch/arm/mm/init.c | |
parent | c8c90860cd3592fac83a349f84a20360a6498727 (diff) | |
download | blackbird-op-linux-7dc50ec7283391dd7a29a80e2a0fb76731a6a7c7.tar.gz blackbird-op-linux-7dc50ec7283391dd7a29a80e2a0fb76731a6a7c7.zip |
ARM: ensure membank array is always sorted
This was missing from the noMMU code, so there was the possibility
of things not working as expected if out of order memory information
was passed.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mm/init.c')
-rw-r--r-- | arch/arm/mm/init.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 7fd9b5eb177f..759878355a05 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -18,6 +18,7 @@ #include <linux/highmem.h> #include <linux/gfp.h> #include <linux/memblock.h> +#include <linux/sort.h> #include <asm/mach-types.h> #include <asm/sections.h> @@ -256,10 +257,19 @@ static void arm_memory_present(void) } #endif +static int __init meminfo_cmp(const void *_a, const void *_b) +{ + const struct membank *a = _a, *b = _b; + long cmp = bank_pfn_start(a) - bank_pfn_start(b); + return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; +} + void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc) { int i; + sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), meminfo_cmp, NULL); + memblock_init(); for (i = 0; i < mi->nr_banks; i++) memblock_add(mi->bank[i].start, mi->bank[i].size); |