x86, memblock: Remove __memblock_x86_find_in_range_size()

Fold it into memblock_x86_find_in_range(), and change bad_addr_size()
to check_reserve_memblock().

So whole memblock_x86_find_in_range_size() code is more readable.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
LKML-Reference: <4CAA4DEC.4000401@kernel.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>

authored by Yinghai Lu and committed by H. Peter Anvin 16c36f74 f1af98c7

+11 -28
+11 -28
arch/x86/mm/memblock.c
··· 8 8 #include <linux/range.h> 9 9 10 10 /* Check for already reserved areas */ 11 - static inline bool __init bad_addr_size(u64 *addrp, u64 *sizep, u64 align) 11 + static bool __init check_with_memblock_reserved_size(u64 *addrp, u64 *sizep, u64 align) 12 12 { 13 13 struct memblock_region *r; 14 14 u64 addr = *addrp, last; ··· 30 30 goto again; 31 31 } 32 32 if (last <= (r->base + r->size) && addr >= r->base) { 33 - (*sizep)++; 33 + *sizep = 0; 34 34 return false; 35 35 } 36 36 } ··· 39 39 *sizep = size; 40 40 } 41 41 return changed; 42 - } 43 - 44 - static u64 __init __memblock_x86_find_in_range_size(u64 ei_start, u64 ei_last, u64 start, 45 - u64 *sizep, u64 align) 46 - { 47 - u64 addr, last; 48 - 49 - addr = round_up(ei_start, align); 50 - if (addr < start) 51 - addr = round_up(start, align); 52 - if (addr >= ei_last) 53 - goto out; 54 - *sizep = ei_last - addr; 55 - while (bad_addr_size(&addr, sizep, align) && addr + *sizep <= ei_last) 56 - ; 57 - last = addr + *sizep; 58 - if (last > ei_last) 59 - goto out; 60 - 61 - return addr; 62 - 63 - out: 64 - return MEMBLOCK_ERROR; 65 42 } 66 43 67 44 /* ··· 53 76 u64 ei_last = ei_start + r->size; 54 77 u64 addr; 55 78 56 - addr = __memblock_x86_find_in_range_size(ei_start, ei_last, start, 57 - sizep, align); 79 + addr = round_up(ei_start, align); 80 + if (addr < start) 81 + addr = round_up(start, align); 82 + if (addr >= ei_last) 83 + continue; 84 + *sizep = ei_last - addr; 85 + while (check_with_memblock_reserved_size(&addr, sizep, align)) 86 + ; 58 87 59 - if (addr != MEMBLOCK_ERROR) 88 + if (*sizep) 60 89 return addr; 61 90 } 62 91