summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorPatrick Mochel <mochel@osdl.org>2002-11-18 09:46:04 -0600
committerPatrick Mochel <mochel@osdl.org>2002-11-18 09:46:04 -0600
commit0d3b7ccf5759e4a8a6dec610bbff7952405b5e7e (patch)
treeb3b3bca0cf627e25dcb38ded1d5653a7c7e88c89 /include/linux
parent80949562050b405845605fd9d2dfa6f4eb3f37c4 (diff)
kobject - expose backend helpers to registration interface.
The interface should now be more sane and protect against races better. kobject_register() was split into two helpers: kobject_init() and kobject_add(). It calls both consecutively, though both are also exposed for use by users that want to use the objects w/o adding them to the object hierarchy. kobject_unregister() was made simply a wrapper for kobject_del() and kobject_put(), which are both also exposed. The guts of kobject_put() was moved into kobject_cleanup(), which it calls when the reference count hits 0. (This was done for clarity). The infrastructure now takes a lot in kobject_get() and kobject_put() when checking and modifying the objects' reference counts. This was an obvious one that hsould have been fixed long ago. kobject_add() increments the refcount of the object, which is decremented when kobject_del() is called. This guarantees that the object's memory cannot be freed if it has been added to the hierarchy, and kobject_del() has not been called on it. kobject_init() is now the function that increments the refcount on the object's subsystem, which is decremented only after its release() method has been called for the object in kobject_cleanup(). The documentation has been updated to reflect these changes.
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/kobject.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 40de16d0a227..7b3157a78f7e 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -24,6 +24,10 @@ struct kobject {
};
extern void kobject_init(struct kobject *);
+extern void kobject_cleanup(struct kobject *);
+
+extern int kobject_add(struct kobject *);
+extern void kobject_del(struct kobject *);
extern int kobject_register(struct kobject *);
extern void kobject_unregister(struct kobject *);