Skip to content

Commit

Permalink
x86, memblock: Remove __memblock_x86_find_in_range_size()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Yinghai Lu authored and H. Peter Anvin committed Oct 6, 2010
1 parent f1af98c commit 16c36f7
Showing 1 changed file with 11 additions and 28 deletions.
39 changes: 11 additions & 28 deletions arch/x86/mm/memblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <linux/range.h>

/* Check for already reserved areas */
static inline bool __init bad_addr_size(u64 *addrp, u64 *sizep, u64 align)
static bool __init check_with_memblock_reserved_size(u64 *addrp, u64 *sizep, u64 align)
{
struct memblock_region *r;
u64 addr = *addrp, last;
Expand All @@ -30,7 +30,7 @@ static inline bool __init bad_addr_size(u64 *addrp, u64 *sizep, u64 align)
goto again;
}
if (last <= (r->base + r->size) && addr >= r->base) {
(*sizep)++;
*sizep = 0;
return false;
}
}
Expand All @@ -41,29 +41,6 @@ static inline bool __init bad_addr_size(u64 *addrp, u64 *sizep, u64 align)
return changed;
}

static u64 __init __memblock_x86_find_in_range_size(u64 ei_start, u64 ei_last, u64 start,
u64 *sizep, u64 align)
{
u64 addr, last;

addr = round_up(ei_start, align);
if (addr < start)
addr = round_up(start, align);
if (addr >= ei_last)
goto out;
*sizep = ei_last - addr;
while (bad_addr_size(&addr, sizep, align) && addr + *sizep <= ei_last)
;
last = addr + *sizep;
if (last > ei_last)
goto out;

return addr;

out:
return MEMBLOCK_ERROR;
}

/*
* Find next free range after start, and size is returned in *sizep
*/
Expand All @@ -76,10 +53,16 @@ u64 __init memblock_x86_find_in_range_size(u64 start, u64 *sizep, u64 align)
u64 ei_last = ei_start + r->size;
u64 addr;

addr = __memblock_x86_find_in_range_size(ei_start, ei_last, start,
sizep, align);
addr = round_up(ei_start, align);
if (addr < start)
addr = round_up(start, align);
if (addr >= ei_last)
continue;
*sizep = ei_last - addr;
while (check_with_memblock_reserved_size(&addr, sizep, align))
;

if (addr != MEMBLOCK_ERROR)
if (*sizep)
return addr;
}

Expand Down

0 comments on commit 16c36f7

Please sign in to comment.