return ret;
}
-static int init_memory_block(struct memory_block **memory,
- struct mem_section *section, unsigned long state)
+static int init_memory_block(struct memory_block **memory, int block_id,
+ unsigned long state)
{
struct memory_block *mem;
unsigned long start_pfn;
- int scn_nr;
int ret = 0;
mem = kzalloc(sizeof(*mem), GFP_KERNEL);
if (!mem)
return -ENOMEM;
- scn_nr = __section_nr(section);
- mem->start_section_nr =
- base_memory_block_id(scn_nr) * sections_per_block;
+ mem->start_section_nr = block_id * sections_per_block;
mem->end_section_nr = mem->start_section_nr + sections_per_block - 1;
mem->state = state;
start_pfn = section_nr_to_pfn(mem->start_section_nr);
static int add_memory_block(int base_section_nr)
{
struct memory_block *mem;
- int i, ret, section_count = 0, section_nr;
+ int i, ret, section_count = 0;
for (i = base_section_nr;
i < base_section_nr + sections_per_block;
- i++) {
- if (!present_section_nr(i))
- continue;
- if (section_count == 0)
- section_nr = i;
- section_count++;
- }
+ i++)
+ if (present_section_nr(i))
+ section_count++;
if (section_count == 0)
return 0;
- ret = init_memory_block(&mem, __nr_to_section(section_nr), MEM_ONLINE);
+ ret = init_memory_block(&mem, base_memory_block_id(base_section_nr),
+ MEM_ONLINE);
if (ret)
return ret;
mem->section_count = section_count;
*/
int hotplug_memory_register(int nid, struct mem_section *section)
{
+ int block_id = base_memory_block_id(__section_nr(section));
int ret = 0;
struct memory_block *mem;
mem->section_count++;
put_device(&mem->dev);
} else {
- ret = init_memory_block(&mem, section, MEM_OFFLINE);
+ ret = init_memory_block(&mem, block_id, MEM_OFFLINE);
if (ret)
goto out;
mem->section_count++;