summaryrefslogtreecommitdiff
path: root/drivers/base/memory.c
diff options
context:
space:
mode:
authorRobin Holt <holt@sgi.com>2010-09-29 19:00:55 (GMT)
committerGreg Kroah-Hartman <gregkh@suse.de>2010-10-22 17:16:44 (GMT)
commit98383031ed77c6eb49ab612166fef9c0efe1604a (patch)
treed34a428c6f52f2982b63d68152a1e29ec2ca9bc0 /drivers/base/memory.c
parentc25d1dfbd403209025df41a737f82ce8f43d93f5 (diff)
downloadlinux-98383031ed77c6eb49ab612166fef9c0efe1604a.tar.xz
driver core: Introduce find_memory_block_hinted which utilizes kset_find_obj_hinted.
Introduce a find_memory_block_hinted() which utilizes the recently added kset_find_obj_hinted(). Signed-off-by: Robin Holt <holt@sgi.com> To: Dave Hansen <haveblue@us.ibm.com> To: Matt Tolentino <matthew.e.tolentino@intel.com> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/memory.c')
-rw-r--r--drivers/base/memory.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 933442f..a799440 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,
return ret;
}
-/*
- * For now, we have a linear search to go find the appropriate
- * memory_block corresponding to a particular phys_index. If
- * this gets to be a real problem, we can always use a radix
- * tree or something here.
- *
- * This could be made generic for all sysdev classes.
- */
-struct memory_block *find_memory_block(struct mem_section *section)
+struct memory_block *find_memory_block_hinted(struct mem_section *section,
+ struct memory_block *hint)
{
struct kobject *kobj;
struct sys_device *sysdev;
struct memory_block *mem;
char name[sizeof(MEMORY_CLASS_NAME) + 9 + 1];
+ kobj = hint ? &hint->sysdev.kobj : NULL;
+
/*
* This only works because we know that section == sysdev->id
* slightly redundant with sysdev_register()
*/
sprintf(&name[0], "%s%d", MEMORY_CLASS_NAME, __section_nr(section));
- kobj = kset_find_obj(&memory_sysdev_class.kset, name);
+ kobj = kset_find_obj_hinted(&memory_sysdev_class.kset, name, kobj);
if (!kobj)
return NULL;
@@ -499,6 +494,19 @@ struct memory_block *find_memory_block(struct mem_section *section)
return mem;
}
+/*
+ * For now, we have a linear search to go find the appropriate
+ * memory_block corresponding to a particular phys_index. If
+ * this gets to be a real problem, we can always use a radix
+ * tree or something here.
+ *
+ * This could be made generic for all sysdev classes.
+ */
+struct memory_block *find_memory_block(struct mem_section *section)
+{
+ return find_memory_block_hinted(section, NULL);
+}
+
int remove_memory_block(unsigned long node_id, struct mem_section *section,
int phys_device)
{