From 0d3b7ccf5759e4a8a6dec610bbff7952405b5e7e Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Mon, 18 Nov 2002 09:46:04 -0600 Subject: 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. --- include/linux/kobject.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/linux') 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 *); -- cgit v1.2.3