diff options
author | Seth Jennings <sjenning@linux.vnet.ibm.com> | 2013-08-20 12:13:00 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-21 11:48:40 -0700 |
commit | d7f80530ad0a71615f54607128c30d2422bf4c02 (patch) | |
tree | 4bbc0f27cf7ef588b54378d6e73e83c149fb470c /drivers/base/memory.c | |
parent | df2b717c667d2cab37d1bbd585e891f10ed2bca4 (diff) |
drivers: base: unshare add_memory_section() from hotplug
add_memory_section() is currently called from both boot time and run
time via hotplug and there is a lot of nastiness to allow for shared
code including an enum parameter to convey the calling context to
add_memory_section().
This patch is the first step in breaking up the messy code sharing by
pulling the hotplug path for add_memory_section() directly into
register_new_memory().
Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/memory.c')
-rw-r--r-- | drivers/base/memory.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index e97519bc3d0..2e9a68c6467 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -647,12 +647,25 @@ static int add_memory_section(int nid, struct mem_section *section, */ int register_new_memory(int nid, struct mem_section *section) { - int ret; + int ret = 0; + struct memory_block *mem; mutex_lock(&mem_sysfs_mutex); - ret = add_memory_section(nid, section, NULL, MEM_OFFLINE, HOTPLUG); - mutex_unlock(&mem_sysfs_mutex); + mem = find_memory_block(section); + if (mem) { + mem->section_count++; + put_device(&mem->dev); + } else { + ret = init_memory_block(&mem, section, MEM_OFFLINE); + if (ret) + goto out; + } + + if (mem->section_count == sections_per_block) + ret = register_mem_sect_under_node(mem, nid); +out: + mutex_unlock(&mem_sysfs_mutex); return ret; } |