aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorNathan Fontenot <nfont@austin.ibm.com>2010-10-19 13:44:20 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-10-22 13:16:44 -0400
commite4619c857d1d769b1172a75ba6b6ebd1186a9c58 (patch)
treea02a286905d4721d378dc1ca42966d12527df70e /drivers/base
parent1ce873abed551a4a0f35e25af9eeec4efdcf341b (diff)
Driver core: Move find_memory_block routine
Move the find_memory_block() routine up to avoid needing a forward declaration in subsequent patches. Signed-off-by: Nathan Fontenot <nfont@austin.ibm.com> Reviewed-by: Robin Holt <holt@sgi.com> Reviewed-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/memory.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index a7994409b9a5..63c25601572d 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -435,39 +435,6 @@ int __weak arch_get_memory_phys_device(unsigned long start_pfn)
435 return 0; 435 return 0;
436} 436}
437 437
438static int add_memory_block(int nid, struct mem_section *section,
439 unsigned long state, enum mem_add_context context)
440{
441 struct memory_block *mem = kzalloc(sizeof(*mem), GFP_KERNEL);
442 unsigned long start_pfn;
443 int ret = 0;
444
445 if (!mem)
446 return -ENOMEM;
447
448 mem->phys_index = __section_nr(section);
449 mem->state = state;
450 mutex_init(&mem->state_mutex);
451 start_pfn = section_nr_to_pfn(mem->phys_index);
452 mem->phys_device = arch_get_memory_phys_device(start_pfn);
453
454 ret = register_memory(mem, section);
455 if (!ret)
456 ret = mem_create_simple_file(mem, phys_index);
457 if (!ret)
458 ret = mem_create_simple_file(mem, state);
459 if (!ret)
460 ret = mem_create_simple_file(mem, phys_device);
461 if (!ret)
462 ret = mem_create_simple_file(mem, removable);
463 if (!ret) {
464 if (context == HOTPLUG)
465 ret = register_mem_sect_under_node(mem, nid);
466 }
467
468 return ret;
469}
470
471struct memory_block *find_memory_block_hinted(struct mem_section *section, 438struct memory_block *find_memory_block_hinted(struct mem_section *section,
472 struct memory_block *hint) 439 struct memory_block *hint)
473{ 440{
@@ -507,6 +474,39 @@ struct memory_block *find_memory_block(struct mem_section *section)
507 return find_memory_block_hinted(section, NULL); 474 return find_memory_block_hinted(section, NULL);
508} 475}
509 476
477static int add_memory_block(int nid, struct mem_section *section,
478 unsigned long state, enum mem_add_context context)
479{
480 struct memory_block *mem = kzalloc(sizeof(*mem), GFP_KERNEL);
481 unsigned long start_pfn;
482 int ret = 0;
483
484 if (!mem)
485 return -ENOMEM;
486
487 mem->phys_index = __section_nr(section);
488 mem->state = state;
489 mutex_init(&mem->state_mutex);
490 start_pfn = section_nr_to_pfn(mem->phys_index);
491 mem->phys_device = arch_get_memory_phys_device(start_pfn);
492
493 ret = register_memory(mem, section);
494 if (!ret)
495 ret = mem_create_simple_file(mem, phys_index);
496 if (!ret)
497 ret = mem_create_simple_file(mem, state);
498 if (!ret)
499 ret = mem_create_simple_file(mem, phys_device);
500 if (!ret)
501 ret = mem_create_simple_file(mem, removable);
502 if (!ret) {
503 if (context == HOTPLUG)
504 ret = register_mem_sect_under_node(mem, nid);
505 }
506
507 return ret;
508}
509
510int remove_memory_block(unsigned long node_id, struct mem_section *section, 510int remove_memory_block(unsigned long node_id, struct mem_section *section,
511 int phys_device) 511 int phys_device)
512{ 512{