summaryrefslogtreecommitdiff
path: root/lib/kobject.c
AgeCommit message (Collapse)Author
2002-12-01kobjects: don't do cleanup if kobject_add() fails.Patrick Mochel
kobject_register() has the rude behavior that it will attempt to clean up the kobject if kobject_add() fails. This replaces that with a WARN_ON() for the return value, and leaves the cleanup to the caller.
2002-11-21Allow subsystem to have attributes, too. Patrick Mochel
This is really handy for subsystems that have any attributes they want to export, esp. if they have just a few, since they don't have to define all of the infrastructure for creating and tearing down the attributes for the high level type that they are. - define struct subsys_attribute for declaring attributes of subsystems themselves. - define subsys_create_file() and subsys_remove_file(). - define subsys_sysfs_ops for forwarding sysfs reads and writes to the subsystem attribute callbacks. - Set the sysfs_ops to be the subsystem ones if the kobject doesn't belong to a subsystem itself (meaning that it is a subsystem).
2002-11-18kobject - expose backend helpers to registration interface.Patrick Mochel
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.
2002-11-18make sure DEBUG is #undef'd so it's really turned offPatrick Mochel
...since macro using it was changed from #if to #ifdef..
2002-10-31kobject: don't create directory for kobject/subsystem if name is NULL.Patrick Mochel
This allows subsystems to exist the hierarchy, but not be exported via the filesystem. This fixes a minor flaw with partitions, as partition objects are children of block devices, though they register with the partition subsystem. Really, the partition subsystem shouldn't have presence in the tree at all, yet still exist.
2002-10-30turn off kobject debugging by default.Patrick Mochel
2002-10-29kobjects: add array of default attributes to subsystems, and create on ↵Patrick Mochel
registration. struct subsystem may now contain a pointer to a NULL-terminated array of default attributes to be exported when an object is registered with the subsystem. kobject registration will check the return values of the directory creation and the creation of each file, and handle it appropriately. The documentation has also been updated.
2002-10-29Introduce struct subsystem.Patrick Mochel
A struct subsystem is basically a collection of objects of a certain type, and some callbacks to operate on objects of that type. subsystems contain embedded kobjects themselves, and have a similar set of library routines that kobjects do, which are mostly just wrappers for the correlating kobject routines. kobjects are inserted in depth-first order into their subsystem's list of objects. Orphan kobjects are also given foster parents that point to their subsystem. This provides a bit more rigidity in the hierarchy, and disallows any orphan kobjects. When an object is unregistered, it is removed from its subsystem's list. When the objects' refcount hits 0, the subsystem's ->release() callback is called. Documentation describing the objects and the interfaces has also been added.
2002-10-29introduce struct kobject: simple, generic object for embedding in other ↵Patrick Mochel
structures. This is not meant to be fancy; just something simple for which we can control the refcount and other common functionality using common code. The basic operations for registration and reference count manipulation are included.