aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/aperture_64.c2
-rw-r--r--arch/x86/kernel/check.c2
-rw-r--r--arch/x86/kernel/e820.c2
-rw-r--r--arch/x86/kernel/setup.c4
-rw-r--r--arch/x86/kernel/trampoline.c2
-rw-r--r--arch/x86/mm/init.c2
-rw-r--r--arch/x86/mm/memblock.c6
-rw-r--r--arch/x86/mm/numa.c6
-rw-r--r--arch/x86/mm/numa_32.c4
-rw-r--r--arch/x86/mm/numa_emulation.c2
-rw-r--r--include/linux/memblock.h4
-rw-r--r--kernel/printk.c2
-rw-r--r--mm/memblock.c21
-rw-r--r--mm/nobootmem.c2
-rw-r--r--mm/page_alloc.c4
15 files changed, 31 insertions, 34 deletions
diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c
index 3d2661ca6542..56363082bbdf 100644
--- a/arch/x86/kernel/aperture_64.c
+++ b/arch/x86/kernel/aperture_64.c
@@ -88,7 +88,7 @@ static u32 __init allocate_aperture(void)
88 */ 88 */
89 addr = memblock_find_in_range(GART_MIN_ADDR, GART_MAX_ADDR, 89 addr = memblock_find_in_range(GART_MIN_ADDR, GART_MAX_ADDR,
90 aper_size, aper_size); 90 aper_size, aper_size);
91 if (addr == MEMBLOCK_ERROR || addr + aper_size > GART_MAX_ADDR) { 91 if (!addr || addr + aper_size > GART_MAX_ADDR) {
92 printk(KERN_ERR 92 printk(KERN_ERR
93 "Cannot allocate aperture memory hole (%lx,%uK)\n", 93 "Cannot allocate aperture memory hole (%lx,%uK)\n",
94 addr, aper_size>>10); 94 addr, aper_size>>10);
diff --git a/arch/x86/kernel/check.c b/arch/x86/kernel/check.c
index 452932d34730..95680fc4df5c 100644
--- a/arch/x86/kernel/check.c
+++ b/arch/x86/kernel/check.c
@@ -86,7 +86,7 @@ void __init setup_bios_corruption_check(void)
86 u64 size; 86 u64 size;
87 addr = memblock_x86_find_in_range_size(addr, &size, PAGE_SIZE); 87 addr = memblock_x86_find_in_range_size(addr, &size, PAGE_SIZE);
88 88
89 if (addr == MEMBLOCK_ERROR) 89 if (!addr)
90 break; 90 break;
91 91
92 if (addr >= corruption_check_size) 92 if (addr >= corruption_check_size)
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 3e2ef8425316..0f9ff58d06d7 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -745,7 +745,7 @@ u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align)
745 745
746 for (start = startt; ; start += size) { 746 for (start = startt; ; start += size) {
747 start = memblock_x86_find_in_range_size(start, &size, align); 747 start = memblock_x86_find_in_range_size(start, &size, align);
748 if (start == MEMBLOCK_ERROR) 748 if (!start)
749 return 0; 749 return 0;
750 if (size >= sizet) 750 if (size >= sizet)
751 break; 751 break;
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index afaf38447ef5..31ffe20d5d27 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -331,7 +331,7 @@ static void __init relocate_initrd(void)
331 ramdisk_here = memblock_find_in_range(0, end_of_lowmem, area_size, 331 ramdisk_here = memblock_find_in_range(0, end_of_lowmem, area_size,
332 PAGE_SIZE); 332 PAGE_SIZE);
333 333
334 if (ramdisk_here == MEMBLOCK_ERROR) 334 if (!ramdisk_here)
335 panic("Cannot find place for new RAMDISK of size %lld\n", 335 panic("Cannot find place for new RAMDISK of size %lld\n",
336 ramdisk_size); 336 ramdisk_size);
337 337
@@ -554,7 +554,7 @@ static void __init reserve_crashkernel(void)
554 crash_base = memblock_find_in_range(alignment, 554 crash_base = memblock_find_in_range(alignment,
555 CRASH_KERNEL_ADDR_MAX, crash_size, alignment); 555 CRASH_KERNEL_ADDR_MAX, crash_size, alignment);
556 556
557 if (crash_base == MEMBLOCK_ERROR) { 557 if (!crash_base) {
558 pr_info("crashkernel reservation failed - No suitable area found.\n"); 558 pr_info("crashkernel reservation failed - No suitable area found.\n");
559 return; 559 return;
560 } 560 }
diff --git a/arch/x86/kernel/trampoline.c b/arch/x86/kernel/trampoline.c
index a91ae7709b49..a1f13ddb06e0 100644
--- a/arch/x86/kernel/trampoline.c
+++ b/arch/x86/kernel/trampoline.c
@@ -14,7 +14,7 @@ void __init setup_trampolines(void)
14 14
15 /* Has to be in very low memory so we can execute real-mode AP code. */ 15 /* Has to be in very low memory so we can execute real-mode AP code. */
16 mem = memblock_find_in_range(0, 1<<20, size, PAGE_SIZE); 16 mem = memblock_find_in_range(0, 1<<20, size, PAGE_SIZE);
17 if (mem == MEMBLOCK_ERROR) 17 if (!mem)
18 panic("Cannot allocate trampoline\n"); 18 panic("Cannot allocate trampoline\n");
19 19
20 x86_trampoline_base = __va(mem); 20 x86_trampoline_base = __va(mem);
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 30326443ab81..13cf05a61605 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -68,7 +68,7 @@ static void __init find_early_table_space(unsigned long end, int use_pse,
68#endif 68#endif
69 69
70 base = memblock_find_in_range(start, good_end, tables, PAGE_SIZE); 70 base = memblock_find_in_range(start, good_end, tables, PAGE_SIZE);
71 if (base == MEMBLOCK_ERROR) 71 if (!base)
72 panic("Cannot find space for the kernel page tables"); 72 panic("Cannot find space for the kernel page tables");
73 73
74 pgt_buf_start = base >> PAGE_SHIFT; 74 pgt_buf_start = base >> PAGE_SHIFT;
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
index 992da5ec5a64..e126117d1b03 100644
--- a/arch/x86/mm/memblock.c
+++ b/arch/x86/mm/memblock.c
@@ -66,7 +66,7 @@ u64 __init memblock_x86_find_in_range_size(u64 start, u64 *sizep, u64 align)
66 return addr; 66 return addr;
67 } 67 }
68 68
69 return MEMBLOCK_ERROR; 69 return 0;
70} 70}
71 71
72static __init struct range *find_range_array(int count) 72static __init struct range *find_range_array(int count)
@@ -78,7 +78,7 @@ static __init struct range *find_range_array(int count)
78 end = memblock.current_limit; 78 end = memblock.current_limit;
79 79
80 mem = memblock_find_in_range(0, end, size, sizeof(struct range)); 80 mem = memblock_find_in_range(0, end, size, sizeof(struct range));
81 if (mem == MEMBLOCK_ERROR) 81 if (!mem)
82 panic("can not find more space for range array"); 82 panic("can not find more space for range array");
83 83
84 /* 84 /*
@@ -274,7 +274,7 @@ u64 __init memblock_x86_find_in_range_node(int nid, u64 start, u64 end, u64 size
274{ 274{
275 u64 addr; 275 u64 addr;
276 addr = find_memory_core_early(nid, size, align, start, end); 276 addr = find_memory_core_early(nid, size, align, start, end);
277 if (addr != MEMBLOCK_ERROR) 277 if (addr)
278 return addr; 278 return addr;
279 279
280 /* Fallback, should already have start end within node range */ 280 /* Fallback, should already have start end within node range */
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index fbeaaf416610..fa1015de5cc0 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -226,10 +226,10 @@ static void __init setup_node_data(int nid, u64 start, u64 end)
226 } else { 226 } else {
227 nd_pa = memblock_x86_find_in_range_node(nid, nd_low, nd_high, 227 nd_pa = memblock_x86_find_in_range_node(nid, nd_low, nd_high,
228 nd_size, SMP_CACHE_BYTES); 228 nd_size, SMP_CACHE_BYTES);
229 if (nd_pa == MEMBLOCK_ERROR) 229 if (!nd_pa)
230 nd_pa = memblock_find_in_range(nd_low, nd_high, 230 nd_pa = memblock_find_in_range(nd_low, nd_high,
231 nd_size, SMP_CACHE_BYTES); 231 nd_size, SMP_CACHE_BYTES);
232 if (nd_pa == MEMBLOCK_ERROR) { 232 if (!nd_pa) {
233 pr_err("Cannot find %zu bytes in node %d\n", 233 pr_err("Cannot find %zu bytes in node %d\n",
234 nd_size, nid); 234 nd_size, nid);
235 return; 235 return;
@@ -395,7 +395,7 @@ static int __init numa_alloc_distance(void)
395 395
396 phys = memblock_find_in_range(0, PFN_PHYS(max_pfn_mapped), 396 phys = memblock_find_in_range(0, PFN_PHYS(max_pfn_mapped),
397 size, PAGE_SIZE); 397 size, PAGE_SIZE);
398 if (phys == MEMBLOCK_ERROR) { 398 if (!phys) {
399 pr_warning("NUMA: Warning: can't allocate distance table!\n"); 399 pr_warning("NUMA: Warning: can't allocate distance table!\n");
400 /* don't retry until explicitly reset */ 400 /* don't retry until explicitly reset */
401 numa_distance = (void *)1LU; 401 numa_distance = (void *)1LU;
diff --git a/arch/x86/mm/numa_32.c b/arch/x86/mm/numa_32.c
index 3adebe7e536a..58878b536ef2 100644
--- a/arch/x86/mm/numa_32.c
+++ b/arch/x86/mm/numa_32.c
@@ -199,7 +199,7 @@ void __init init_alloc_remap(int nid, u64 start, u64 end)
199 199
200 /* allocate node memory and the lowmem remap area */ 200 /* allocate node memory and the lowmem remap area */
201 node_pa = memblock_find_in_range(start, end, size, LARGE_PAGE_BYTES); 201 node_pa = memblock_find_in_range(start, end, size, LARGE_PAGE_BYTES);
202 if (node_pa == MEMBLOCK_ERROR) { 202 if (!node_pa) {
203 pr_warning("remap_alloc: failed to allocate %lu bytes for node %d\n", 203 pr_warning("remap_alloc: failed to allocate %lu bytes for node %d\n",
204 size, nid); 204 size, nid);
205 return; 205 return;
@@ -209,7 +209,7 @@ void __init init_alloc_remap(int nid, u64 start, u64 end)
209 remap_pa = memblock_find_in_range(min_low_pfn << PAGE_SHIFT, 209 remap_pa = memblock_find_in_range(min_low_pfn << PAGE_SHIFT,
210 max_low_pfn << PAGE_SHIFT, 210 max_low_pfn << PAGE_SHIFT,
211 size, LARGE_PAGE_BYTES); 211 size, LARGE_PAGE_BYTES);
212 if (remap_pa == MEMBLOCK_ERROR) { 212 if (!remap_pa) {
213 pr_warning("remap_alloc: failed to allocate %lu bytes remap area for node %d\n", 213 pr_warning("remap_alloc: failed to allocate %lu bytes remap area for node %d\n",
214 size, nid); 214 size, nid);
215 memblock_x86_free_range(node_pa, node_pa + size); 215 memblock_x86_free_range(node_pa, node_pa + size);
diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c
index d0ed086b6247..e3d471c20cdc 100644
--- a/arch/x86/mm/numa_emulation.c
+++ b/arch/x86/mm/numa_emulation.c
@@ -351,7 +351,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
351 351
352 phys = memblock_find_in_range(0, PFN_PHYS(max_pfn_mapped), 352 phys = memblock_find_in_range(0, PFN_PHYS(max_pfn_mapped),
353 phys_size, PAGE_SIZE); 353 phys_size, PAGE_SIZE);
354 if (phys == MEMBLOCK_ERROR) { 354 if (!phys) {
355 pr_warning("NUMA: Warning: can't allocate copy of distance table, disabling emulation\n"); 355 pr_warning("NUMA: Warning: can't allocate copy of distance table, disabling emulation\n");
356 goto no_emu; 356 goto no_emu;
357 } 357 }
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 7525e38c434d..d235ec5fe678 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -2,8 +2,6 @@
2#define _LINUX_MEMBLOCK_H 2#define _LINUX_MEMBLOCK_H
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5#define MEMBLOCK_ERROR 0
6
7#ifdef CONFIG_HAVE_MEMBLOCK 5#ifdef CONFIG_HAVE_MEMBLOCK
8/* 6/*
9 * Logical memory blocks. 7 * Logical memory blocks.
@@ -164,7 +162,7 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo
164#else 162#else
165static inline phys_addr_t memblock_alloc(phys_addr_t size, phys_addr_t align) 163static inline phys_addr_t memblock_alloc(phys_addr_t size, phys_addr_t align)
166{ 164{
167 return MEMBLOCK_ERROR; 165 return 0;
168} 166}
169 167
170#endif /* CONFIG_HAVE_MEMBLOCK */ 168#endif /* CONFIG_HAVE_MEMBLOCK */
diff --git a/kernel/printk.c b/kernel/printk.c
index 35185392173f..b1d5a6174d65 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -199,7 +199,7 @@ void __init setup_log_buf(int early)
199 unsigned long mem; 199 unsigned long mem;
200 200
201 mem = memblock_alloc(new_log_buf_len, PAGE_SIZE); 201 mem = memblock_alloc(new_log_buf_len, PAGE_SIZE);
202 if (mem == MEMBLOCK_ERROR) 202 if (!mem)
203 return; 203 return;
204 new_log_buf = __va(mem); 204 new_log_buf = __va(mem);
205 } else { 205 } else {
diff --git a/mm/memblock.c b/mm/memblock.c
index 9882a88d4a10..196993661346 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -74,7 +74,7 @@ static phys_addr_t __init_memblock memblock_find_region(phys_addr_t start, phys_
74 74
75 /* In case, huge size is requested */ 75 /* In case, huge size is requested */
76 if (end < size) 76 if (end < size)
77 return MEMBLOCK_ERROR; 77 return 0;
78 78
79 base = round_down(end - size, align); 79 base = round_down(end - size, align);
80 80
@@ -94,7 +94,7 @@ static phys_addr_t __init_memblock memblock_find_region(phys_addr_t start, phys_
94 base = round_down(res_base - size, align); 94 base = round_down(res_base - size, align);
95 } 95 }
96 96
97 return MEMBLOCK_ERROR; 97 return 0;
98} 98}
99 99
100static phys_addr_t __init_memblock memblock_find_base(phys_addr_t size, 100static phys_addr_t __init_memblock memblock_find_base(phys_addr_t size,
@@ -126,10 +126,10 @@ static phys_addr_t __init_memblock memblock_find_base(phys_addr_t size,
126 if (bottom >= top) 126 if (bottom >= top)
127 continue; 127 continue;
128 found = memblock_find_region(bottom, top, size, align); 128 found = memblock_find_region(bottom, top, size, align);
129 if (found != MEMBLOCK_ERROR) 129 if (found)
130 return found; 130 return found;
131 } 131 }
132 return MEMBLOCK_ERROR; 132 return 0;
133} 133}
134 134
135/* 135/*
@@ -214,10 +214,10 @@ static int __init_memblock memblock_double_array(struct memblock_type *type)
214 */ 214 */
215 if (use_slab) { 215 if (use_slab) {
216 new_array = kmalloc(new_size, GFP_KERNEL); 216 new_array = kmalloc(new_size, GFP_KERNEL);
217 addr = new_array == NULL ? MEMBLOCK_ERROR : __pa(new_array); 217 addr = new_array ? __pa(new_array) : 0;
218 } else 218 } else
219 addr = memblock_find_base(new_size, sizeof(phys_addr_t), 0, MEMBLOCK_ALLOC_ACCESSIBLE); 219 addr = memblock_find_base(new_size, sizeof(phys_addr_t), 0, MEMBLOCK_ALLOC_ACCESSIBLE);
220 if (addr == MEMBLOCK_ERROR) { 220 if (!addr) {
221 pr_err("memblock: Failed to double %s array from %ld to %ld entries !\n", 221 pr_err("memblock: Failed to double %s array from %ld to %ld entries !\n",
222 memblock_type_name(type), type->max, type->max * 2); 222 memblock_type_name(type), type->max, type->max * 2);
223 return -1; 223 return -1;
@@ -478,8 +478,7 @@ phys_addr_t __init __memblock_alloc_base(phys_addr_t size, phys_addr_t align, ph
478 size = round_up(size, align); 478 size = round_up(size, align);
479 479
480 found = memblock_find_base(size, align, 0, max_addr); 480 found = memblock_find_base(size, align, 0, max_addr);
481 if (found != MEMBLOCK_ERROR && 481 if (found && !memblock_add_region(&memblock.reserved, found, size))
482 !memblock_add_region(&memblock.reserved, found, size))
483 return found; 482 return found;
484 483
485 return 0; 484 return 0;
@@ -559,14 +558,14 @@ static phys_addr_t __init memblock_alloc_nid_region(struct memblock_region *mp,
559 this_end = memblock_nid_range(start, end, &this_nid); 558 this_end = memblock_nid_range(start, end, &this_nid);
560 if (this_nid == nid) { 559 if (this_nid == nid) {
561 phys_addr_t ret = memblock_find_region(start, this_end, size, align); 560 phys_addr_t ret = memblock_find_region(start, this_end, size, align);
562 if (ret != MEMBLOCK_ERROR && 561 if (ret &&
563 !memblock_add_region(&memblock.reserved, ret, size)) 562 !memblock_add_region(&memblock.reserved, ret, size))
564 return ret; 563 return ret;
565 } 564 }
566 start = this_end; 565 start = this_end;
567 } 566 }
568 567
569 return MEMBLOCK_ERROR; 568 return 0;
570} 569}
571 570
572phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid) 571phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid)
@@ -588,7 +587,7 @@ phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int n
588 for (i = 0; i < mem->cnt; i++) { 587 for (i = 0; i < mem->cnt; i++) {
589 phys_addr_t ret = memblock_alloc_nid_region(&mem->regions[i], 588 phys_addr_t ret = memblock_alloc_nid_region(&mem->regions[i],
590 size, align, nid); 589 size, align, nid);
591 if (ret != MEMBLOCK_ERROR) 590 if (ret)
592 return ret; 591 return ret;
593 } 592 }
594 593
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 6e93dc7f2586..5b0eb06ecb4e 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -43,7 +43,7 @@ static void * __init __alloc_memory_core_early(int nid, u64 size, u64 align,
43 43
44 addr = find_memory_core_early(nid, size, align, goal, limit); 44 addr = find_memory_core_early(nid, size, align, goal, limit);
45 45
46 if (addr == MEMBLOCK_ERROR) 46 if (!addr)
47 return NULL; 47 return NULL;
48 48
49 ptr = phys_to_virt(addr); 49 ptr = phys_to_virt(addr);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b6da6ed818a8..c7f0e5be4a31 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3878,13 +3878,13 @@ u64 __init find_memory_core_early(int nid, u64 size, u64 align,
3878 3878
3879 addr = memblock_find_in_range(final_start, final_end, size, align); 3879 addr = memblock_find_in_range(final_start, final_end, size, align);
3880 3880
3881 if (addr == MEMBLOCK_ERROR) 3881 if (!addr)
3882 continue; 3882 continue;
3883 3883
3884 return addr; 3884 return addr;
3885 } 3885 }
3886 3886
3887 return MEMBLOCK_ERROR; 3887 return 0;
3888} 3888}
3889#endif 3889#endif
3890 3890