diff options
-rw-r--r-- | drivers/of/of_reserved_mem.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 8c07d7da5256..6a36bc0b3d64 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c | |||
@@ -34,22 +34,15 @@ static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size, | |||
34 | 34 | ||
35 | end = !end ? MEMBLOCK_ALLOC_ANYWHERE : end; | 35 | end = !end ? MEMBLOCK_ALLOC_ANYWHERE : end; |
36 | align = !align ? SMP_CACHE_BYTES : align; | 36 | align = !align ? SMP_CACHE_BYTES : align; |
37 | base = memblock_phys_alloc_range(size, align, 0, end); | 37 | base = memblock_find_in_range(start, end, size, align); |
38 | if (!base) | 38 | if (!base) |
39 | return -ENOMEM; | 39 | return -ENOMEM; |
40 | 40 | ||
41 | /* | ||
42 | * Check if the allocated region fits in to start..end window | ||
43 | */ | ||
44 | if (base < start) { | ||
45 | memblock_free(base, size); | ||
46 | return -ENOMEM; | ||
47 | } | ||
48 | |||
49 | *res_base = base; | 41 | *res_base = base; |
50 | if (nomap) | 42 | if (nomap) |
51 | return memblock_remove(base, size); | 43 | return memblock_remove(base, size); |
52 | return 0; | 44 | |
45 | return memblock_reserve(base, size); | ||
53 | } | 46 | } |
54 | 47 | ||
55 | /** | 48 | /** |