mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-03-30 19:07:15 +00:00
memblock: Move memblock arrays to static storage in memblock.c and make their size a variable
This is in preparation for having resizable arrays. Note that we still allocate one more than needed, this is unchanged from the previous implementation. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This commit is contained in:
parent
4734b594c6
commit
bf23c51f1f
2 changed files with 13 additions and 4 deletions
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include <asm/memblock.h>
|
#include <asm/memblock.h>
|
||||||
|
|
||||||
#define MAX_MEMBLOCK_REGIONS 128
|
#define INIT_MEMBLOCK_REGIONS 128
|
||||||
|
|
||||||
struct memblock_region {
|
struct memblock_region {
|
||||||
phys_addr_t base;
|
phys_addr_t base;
|
||||||
|
@ -26,8 +26,9 @@ struct memblock_region {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct memblock_type {
|
struct memblock_type {
|
||||||
unsigned long cnt;
|
unsigned long cnt; /* number of regions */
|
||||||
struct memblock_region regions[MAX_MEMBLOCK_REGIONS+1];
|
unsigned long max; /* size of the allocated array */
|
||||||
|
struct memblock_region *regions;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct memblock {
|
struct memblock {
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
struct memblock memblock;
|
struct memblock memblock;
|
||||||
|
|
||||||
static int memblock_debug;
|
static int memblock_debug;
|
||||||
|
static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS + 1];
|
||||||
|
static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_REGIONS + 1];
|
||||||
|
|
||||||
static int __init early_memblock(char *p)
|
static int __init early_memblock(char *p)
|
||||||
{
|
{
|
||||||
|
@ -104,6 +106,12 @@ static void memblock_coalesce_regions(struct memblock_type *type,
|
||||||
|
|
||||||
void __init memblock_init(void)
|
void __init memblock_init(void)
|
||||||
{
|
{
|
||||||
|
/* Hookup the initial arrays */
|
||||||
|
memblock.memory.regions = memblock_memory_init_regions;
|
||||||
|
memblock.memory.max = INIT_MEMBLOCK_REGIONS;
|
||||||
|
memblock.reserved.regions = memblock_reserved_init_regions;
|
||||||
|
memblock.reserved.max = INIT_MEMBLOCK_REGIONS;
|
||||||
|
|
||||||
/* Create a dummy zero size MEMBLOCK which will get coalesced away later.
|
/* Create a dummy zero size MEMBLOCK which will get coalesced away later.
|
||||||
* This simplifies the memblock_add() code below...
|
* This simplifies the memblock_add() code below...
|
||||||
*/
|
*/
|
||||||
|
@ -169,7 +177,7 @@ static long memblock_add_region(struct memblock_type *type, phys_addr_t base, ph
|
||||||
|
|
||||||
if (coalesced)
|
if (coalesced)
|
||||||
return coalesced;
|
return coalesced;
|
||||||
if (type->cnt >= MAX_MEMBLOCK_REGIONS)
|
if (type->cnt >= type->max)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Couldn't coalesce the MEMBLOCK, so add it to the sorted table. */
|
/* Couldn't coalesce the MEMBLOCK, so add it to the sorted table. */
|
||||||
|
|
Loading…
Add table
Reference in a new issue