summaryrefslogtreecommitdiff
path: root/lib/kobject.c
diff options
context:
space:
mode:
authorPatrick Mochel <mochel@osdl.org>2003-06-10 22:06:07 -0700
committerPatrick Mochel <mochel@osdl.org>2003-06-10 22:06:07 -0700
commitc5c3f275a13bfefd27ec9add28a692e5c4c9cb1c (patch)
tree9d6c19d32ffa138caa7844139803f097715ddaaf /lib/kobject.c
parentd4841357d6c28532f634c929a6a093c51f219a33 (diff)
[kobject] Don't specially order objects in lists based on parent.
Previously, we would insert kobjects into their kset's lists at different locations based on if they had a parent or not - We kept an explicit depth-first list by placing devices directly before their parents. However, we don't need strict ordering. Assuming that a subordinate device is always added after its parent (true), then by adding them to the end of the list, then subordinate objects will always be farther down the list than their parent objects. We don't need to do anything special..
Diffstat (limited to 'lib/kobject.c')
-rw-r--r--lib/kobject.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index 661bf12797cf..e2378597b989 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -252,14 +252,15 @@ int kobject_add(struct kobject * kobj)
if (kobj->kset) {
down_write(&kobj->kset->subsys->rwsem);
- if (parent)
- list_add_tail(&kobj->entry,&parent->entry);
- else {
- list_add_tail(&kobj->entry,&kobj->kset->list);
- kobj->parent = kobject_get(&kobj->kset->kobj);
- }
+
+ if (!parent)
+ parent = kobject_get(&kobj->kset->kobj);
+
+ list_add_tail(&kobj->entry,&kobj->kset->list);
up_write(&kobj->kset->subsys->rwsem);
}
+ kobj->parent = parent;
+
error = create_dir(kobj);
if (error)
unlink(kobj);