aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
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{