diff options
author | Patrick Mochel <mochel@osdl.org> | 2002-12-19 03:46:29 -0600 |
---|---|---|
committer | Patrick Mochel <mochel@osdl.org> | 2002-12-19 03:46:29 -0600 |
commit | 039294682d6a32455623da81076597a6f8da39b3 (patch) | |
tree | 0185e759574e1c6bd1772a3ec47e6b1830ce1390 /lib | |
parent | 75fb58eebfbaca27864b925e49370ccbf1bc33ba (diff) | |
download | history-039294682d6a32455623da81076597a6f8da39b3.tar.gz |
kobjects: minor updates
- check if subsystem is NULL during subsys_get().
- Don't increment parent's reference count before we check if we have a
valid kobject during kobject_add()
- Do kobject_add() in subsys_register(), instead of kobject_register(),
since we've already done kobject_init().
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kobject.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/kobject.c b/lib/kobject.c index 04b1fd760d45dc..24807bc72f81b8 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -74,10 +74,13 @@ int kobject_add(struct kobject * kobj) { int error = 0; struct subsystem * s = kobj->subsys; - struct kobject * parent = kobject_get(kobj->parent); + struct kobject * parent; if (!(kobj = kobject_get(kobj))) return -ENOENT; + + parent = kobject_get(kobj->parent); + pr_debug("kobject %s: registering. parent: %s, subsys: %s\n", kobj->name, parent ? parent->name : "<NULL>", kobj->subsys ? kobj->subsys->kobj.name : "<NULL>" ); @@ -93,8 +96,8 @@ int kobject_add(struct kobject * kobj) up_write(&s->rwsem); } error = create_dir(kobj); - if (error && kobj->parent) - kobject_put(kobj->parent); + if (error && parent) + kobject_put(parent); return error; } @@ -218,7 +221,7 @@ int subsystem_register(struct subsystem * s) s->kobj.parent = &s->parent->kobj; pr_debug("subsystem %s: registering, parent: %s\n", s->kobj.name,s->parent ? s->parent->kobj.name : "<none>"); - return kobject_register(&s->kobj); + return kobject_add(&s->kobj); } void subsystem_unregister(struct subsystem * s) |