diff options
-rw-r--r-- | drivers/base/memory.c | 41 | ||||
-rw-r--r-- | include/linux/memory.h | 1 |
2 files changed, 14 insertions, 28 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 2e9a68c64679..a9e9c0902cce 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
@@ -602,40 +602,29 @@ static int init_memory_block(struct memory_block **memory, | |||
602 | return ret; | 602 | return ret; |
603 | } | 603 | } |
604 | 604 | ||
605 | static int add_memory_section(int nid, struct mem_section *section, | 605 | static int add_memory_section(struct mem_section *section, |
606 | struct memory_block **mem_p, | 606 | struct memory_block **mem_p) |
607 | unsigned long state, enum mem_add_context context) | ||
608 | { | 607 | { |
609 | struct memory_block *mem = NULL; | 608 | struct memory_block *mem = NULL; |
610 | int scn_nr = __section_nr(section); | 609 | int scn_nr = __section_nr(section); |
611 | int ret = 0; | 610 | int ret = 0; |
612 | 611 | ||
613 | if (context == BOOT) { | 612 | if (mem_p && *mem_p) { |
614 | /* same memory block ? */ | 613 | if (scn_nr >= (*mem_p)->start_section_nr && |
615 | if (mem_p && *mem_p) | 614 | scn_nr <= (*mem_p)->end_section_nr) { |
616 | if (scn_nr >= (*mem_p)->start_section_nr && | 615 | mem = *mem_p; |
617 | scn_nr <= (*mem_p)->end_section_nr) { | 616 | get_device(&mem->dev); |
618 | mem = *mem_p; | 617 | } |
619 | get_device(&mem->dev); | 618 | } |
620 | } | ||
621 | } else | ||
622 | mem = find_memory_block(section); | ||
623 | 619 | ||
624 | if (mem) { | 620 | if (mem) { |
625 | mem->section_count++; | 621 | mem->section_count++; |
626 | put_device(&mem->dev); | 622 | put_device(&mem->dev); |
627 | } else { | 623 | } else { |
628 | ret = init_memory_block(&mem, section, state); | 624 | ret = init_memory_block(&mem, section, MEM_ONLINE); |
629 | /* store memory_block pointer for next loop */ | 625 | /* store memory_block pointer for next loop */ |
630 | if (!ret && context == BOOT) | 626 | if (!ret && mem_p) |
631 | if (mem_p) | 627 | *mem_p = mem; |
632 | *mem_p = mem; | ||
633 | } | ||
634 | |||
635 | if (!ret) { | ||
636 | if (context == HOTPLUG && | ||
637 | mem->section_count == sections_per_block) | ||
638 | ret = register_mem_sect_under_node(mem, nid); | ||
639 | } | 628 | } |
640 | 629 | ||
641 | return ret; | 630 | return ret; |
@@ -764,10 +753,8 @@ int __init memory_dev_init(void) | |||
764 | if (!present_section_nr(i)) | 753 | if (!present_section_nr(i)) |
765 | continue; | 754 | continue; |
766 | /* don't need to reuse memory_block if only one per block */ | 755 | /* don't need to reuse memory_block if only one per block */ |
767 | err = add_memory_section(0, __nr_to_section(i), | 756 | err = add_memory_section(__nr_to_section(i), |
768 | (sections_per_block == 1) ? NULL : &mem, | 757 | (sections_per_block == 1) ? NULL : &mem); |
769 | MEM_ONLINE, | ||
770 | BOOT); | ||
771 | if (!ret) | 758 | if (!ret) |
772 | ret = err; | 759 | ret = err; |
773 | } | 760 | } |
diff --git a/include/linux/memory.h b/include/linux/memory.h index 85c31a8e2904..4c89fb0c8f4c 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h | |||
@@ -125,7 +125,6 @@ extern struct memory_block *find_memory_block_hinted(struct mem_section *, | |||
125 | struct memory_block *); | 125 | struct memory_block *); |
126 | extern struct memory_block *find_memory_block(struct mem_section *); | 126 | extern struct memory_block *find_memory_block(struct mem_section *); |
127 | #define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<<PAGE_SHIFT) | 127 | #define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<<PAGE_SHIFT) |
128 | enum mem_add_context { BOOT, HOTPLUG }; | ||
129 | #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */ | 128 | #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */ |
130 | 129 | ||
131 | #ifdef CONFIG_MEMORY_HOTPLUG | 130 | #ifdef CONFIG_MEMORY_HOTPLUG |