]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - mm/memblock.c
MAINTAINERS: merge s3c-244x sections
[net-next-2.6.git] / mm / memblock.c
index 65e3ba8d09fb310546dbd24da24f1559631b3840..400dc62697d78056eaa12c7a91ca9f9daa1d4c77 100644 (file)
@@ -99,19 +99,24 @@ long __init_memblock memblock_overlaps_region(struct memblock_type *type, phys_a
  * are top-down.
  */
 
-static phys_addr_t __init memblock_find_region(phys_addr_t start, phys_addr_t end,
+static phys_addr_t __init_memblock memblock_find_region(phys_addr_t start, phys_addr_t end,
                                          phys_addr_t size, phys_addr_t align)
 {
        phys_addr_t base, res_base;
        long j;
 
+       /* In case, huge size is requested */
+       if (end < size)
+               return MEMBLOCK_ERROR;
+
+       base = memblock_align_down((end - size), align);
+
        /* Prevent allocations returning 0 as it's also used to
         * indicate an allocation failure
         */
        if (start == 0)
                start = PAGE_SIZE;
 
-       base = memblock_align_down((end - size), align);
        while (start <= base) {
                j = memblock_overlaps_region(&memblock.reserved, base, size);
                if (j < 0)
@@ -125,8 +130,8 @@ static phys_addr_t __init memblock_find_region(phys_addr_t start, phys_addr_t en
        return MEMBLOCK_ERROR;
 }
 
-static phys_addr_t __init memblock_find_base(phys_addr_t size, phys_addr_t align,
-                                       phys_addr_t start, phys_addr_t end)
+static phys_addr_t __init_memblock memblock_find_base(phys_addr_t size,
+                       phys_addr_t align, phys_addr_t start, phys_addr_t end)
 {
        long i;
 
@@ -439,12 +444,12 @@ long __init_memblock memblock_remove(phys_addr_t base, phys_addr_t size)
        return __memblock_remove(&memblock.memory, base, size);
 }
 
-long __init memblock_free(phys_addr_t base, phys_addr_t size)
+long __init_memblock memblock_free(phys_addr_t base, phys_addr_t size)
 {
        return __memblock_remove(&memblock.reserved, base, size);
 }
 
-long __init memblock_reserve(phys_addr_t base, phys_addr_t size)
+long __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)
 {
        struct memblock_type *_rgn = &memblock.reserved;
 
@@ -648,7 +653,7 @@ void __init memblock_enforce_memory_limit(phys_addr_t memory_limit)
        }
 }
 
-static int memblock_search(struct memblock_type *type, phys_addr_t addr)
+static int __init_memblock memblock_search(struct memblock_type *type, phys_addr_t addr)
 {
        unsigned int left = 0, right = type->cnt;
 
@@ -671,12 +676,12 @@ int __init memblock_is_reserved(phys_addr_t addr)
        return memblock_search(&memblock.reserved, addr) != -1;
 }
 
-int memblock_is_memory(phys_addr_t addr)
+int __init_memblock memblock_is_memory(phys_addr_t addr)
 {
        return memblock_search(&memblock.memory, addr) != -1;
 }
 
-int memblock_is_region_memory(phys_addr_t base, phys_addr_t size)
+int __init_memblock memblock_is_region_memory(phys_addr_t base, phys_addr_t size)
 {
        int idx = memblock_search(&memblock.reserved, base);
 
@@ -693,7 +698,7 @@ int __init_memblock memblock_is_region_reserved(phys_addr_t base, phys_addr_t si
 }
 
 
-void __init memblock_set_current_limit(phys_addr_t limit)
+void __init_memblock memblock_set_current_limit(phys_addr_t limit)
 {
        memblock.current_limit = limit;
 }
@@ -747,6 +752,12 @@ void __init memblock_analyze(void)
 
 void __init memblock_init(void)
 {
+       static int init_done __initdata = 0;
+
+       if (init_done)
+               return;
+       init_done = 1;
+
        /* Hookup the initial arrays */
        memblock.memory.regions = memblock_memory_init_regions;
        memblock.memory.max             = INIT_MEMBLOCK_REGIONS;