Commit 37a7bd62 authored by Seth Jennings's avatar Seth Jennings Committed by Greg Kroah-Hartman

drivers: base: reduce add_memory_section() for boot-time only

Now that add_memory_section() is only called from boot time, reduce
the logic and remove the enum.
Signed-off-by: default avatarSeth Jennings <sjenning@linux.vnet.ibm.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d7f80530
...@@ -602,42 +602,31 @@ static int init_memory_block(struct memory_block **memory, ...@@ -602,42 +602,31 @@ static int init_memory_block(struct memory_block **memory,
return ret; return ret;
} }
static int add_memory_section(int nid, struct mem_section *section, static int add_memory_section(struct mem_section *section,
struct memory_block **mem_p, struct memory_block **mem_p)
unsigned long state, enum mem_add_context context)
{ {
struct memory_block *mem = NULL; struct memory_block *mem = NULL;
int scn_nr = __section_nr(section); int scn_nr = __section_nr(section);
int ret = 0; int ret = 0;
if (context == BOOT) { if (mem_p && *mem_p) {
/* same memory block ? */
if (mem_p && *mem_p)
if (scn_nr >= (*mem_p)->start_section_nr && if (scn_nr >= (*mem_p)->start_section_nr &&
scn_nr <= (*mem_p)->end_section_nr) { scn_nr <= (*mem_p)->end_section_nr) {
mem = *mem_p; mem = *mem_p;
get_device(&mem->dev); get_device(&mem->dev);
} }
} else }
mem = find_memory_block(section);
if (mem) { if (mem) {
mem->section_count++; mem->section_count++;
put_device(&mem->dev); put_device(&mem->dev);
} else { } else {
ret = init_memory_block(&mem, section, state); ret = init_memory_block(&mem, section, MEM_ONLINE);
/* store memory_block pointer for next loop */ /* store memory_block pointer for next loop */
if (!ret && context == BOOT) if (!ret && mem_p)
if (mem_p)
*mem_p = mem; *mem_p = mem;
} }
if (!ret) {
if (context == HOTPLUG &&
mem->section_count == sections_per_block)
ret = register_mem_sect_under_node(mem, nid);
}
return ret; return ret;
} }
...@@ -764,10 +753,8 @@ int __init memory_dev_init(void) ...@@ -764,10 +753,8 @@ int __init memory_dev_init(void)
if (!present_section_nr(i)) if (!present_section_nr(i))
continue; continue;
/* don't need to reuse memory_block if only one per block */ /* don't need to reuse memory_block if only one per block */
err = add_memory_section(0, __nr_to_section(i), err = add_memory_section(__nr_to_section(i),
(sections_per_block == 1) ? NULL : &mem, (sections_per_block == 1) ? NULL : &mem);
MEM_ONLINE,
BOOT);
if (!ret) if (!ret)
ret = err; ret = err;
} }
......
...@@ -125,7 +125,6 @@ extern struct memory_block *find_memory_block_hinted(struct mem_section *, ...@@ -125,7 +125,6 @@ extern struct memory_block *find_memory_block_hinted(struct mem_section *,
struct memory_block *); struct memory_block *);
extern struct memory_block *find_memory_block(struct mem_section *); extern struct memory_block *find_memory_block(struct mem_section *);
#define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<<PAGE_SHIFT) #define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<<PAGE_SHIFT)
enum mem_add_context { BOOT, HOTPLUG };
#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */ #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
#ifdef CONFIG_MEMORY_HOTPLUG #ifdef CONFIG_MEMORY_HOTPLUG
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment