Skip to content

Commit

Permalink
drivers: base: unshare add_memory_section() from hotplug
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Seth Jennings authored and Greg Kroah-Hartman committed Aug 21, 2013
1 parent df2b717 commit d7f8053
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions drivers/base/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit d7f8053

Please sign in to comment.