aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/memory.c28
-rw-r--r--include/linux/memory.h2
2 files changed, 20 insertions, 10 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 933442f40321..a7994409b9a5 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -468,28 +468,23 @@ static int add_memory_block(int nid, struct mem_section *section,
468 return ret; 468 return ret;
469} 469}
470 470
471/* 471struct memory_block *find_memory_block_hinted(struct mem_section *section,
472 * For now, we have a linear search to go find the appropriate 472 struct memory_block *hint)
473 * memory_block corresponding to a particular phys_index. If
474 * this gets to be a real problem, we can always use a radix
475 * tree or something here.
476 *
477 * This could be made generic for all sysdev classes.
478 */
479struct memory_block *find_memory_block(struct mem_section *section)
480{ 473{
481 struct kobject *kobj; 474 struct kobject *kobj;
482 struct sys_device *sysdev; 475 struct sys_device *sysdev;
483 struct memory_block *mem; 476 struct memory_block *mem;
484 char name[sizeof(MEMORY_CLASS_NAME) + 9 + 1]; 477 char name[sizeof(MEMORY_CLASS_NAME) + 9 + 1];
485 478
479 kobj = hint ? &hint->sysdev.kobj : NULL;
480
486 /* 481 /*
487 * This only works because we know that section == sysdev->id 482 * This only works because we know that section == sysdev->id
488 * slightly redundant with sysdev_register() 483 * slightly redundant with sysdev_register()
489 */ 484 */
490 sprintf(&name[0], "%s%d", MEMORY_CLASS_NAME, __section_nr(section)); 485 sprintf(&name[0], "%s%d", MEMORY_CLASS_NAME, __section_nr(section));
491 486
492 kobj = kset_find_obj(&memory_sysdev_class.kset, name); 487 kobj = kset_find_obj_hinted(&memory_sysdev_class.kset, name, kobj);
493 if (!kobj) 488 if (!kobj)
494 return NULL; 489 return NULL;
495 490
@@ -499,6 +494,19 @@ struct memory_block *find_memory_block(struct mem_section *section)
499 return mem; 494 return mem;
500} 495}
501 496
497/*
498 * For now, we have a linear search to go find the appropriate
499 * memory_block corresponding to a particular phys_index. If
500 * this gets to be a real problem, we can always use a radix
501 * tree or something here.
502 *
503 * This could be made generic for all sysdev classes.
504 */
505struct memory_block *find_memory_block(struct mem_section *section)
506{
507 return find_memory_block_hinted(section, NULL);
508}
509
502int remove_memory_block(unsigned long node_id, struct mem_section *section, 510int remove_memory_block(unsigned long node_id, struct mem_section *section,
503 int phys_device) 511 int phys_device)
504{ 512{
diff --git a/include/linux/memory.h b/include/linux/memory.h
index 85582e1bcee9..c4f3127dbd48 100644
--- a/include/linux/memory.h
+++ b/include/linux/memory.h
@@ -113,6 +113,8 @@ extern int memory_dev_init(void);
113extern int remove_memory_block(unsigned long, struct mem_section *, int); 113extern int remove_memory_block(unsigned long, struct mem_section *, int);
114extern int memory_notify(unsigned long val, void *v); 114extern int memory_notify(unsigned long val, void *v);
115extern int memory_isolate_notify(unsigned long val, void *v); 115extern int memory_isolate_notify(unsigned long val, void *v);
116extern struct memory_block *find_memory_block_hinted(struct mem_section *,
117 struct memory_block *);
116extern struct memory_block *find_memory_block(struct mem_section *); 118extern struct memory_block *find_memory_block(struct mem_section *);
117#define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<<PAGE_SHIFT) 119#define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<<PAGE_SHIFT)
118enum mem_add_context { BOOT, HOTPLUG }; 120enum mem_add_context { BOOT, HOTPLUG };