diff options
| author | Patrick Mochel <mochel@osdl.org> | 2002-10-29 19:47:41 -0800 |
|---|---|---|
| committer | Patrick Mochel <mochel@osdl.org> | 2002-10-29 19:47:41 -0800 |
| commit | a6c066de9d449b0bbe2efbf6431b19c270e02060 (patch) | |
| tree | 1039c0c2a45cfd11703ff3d4347e2becd2331627 /include/linux/kobject.h | |
| parent | 0862416ecefa629a52f3ee0907206e9633ca45c3 (diff) | |
Introduce struct subsystem.
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.
Diffstat (limited to 'include/linux/kobject.h')
| -rw-r--r-- | include/linux/kobject.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 12431a980712..32dfaaf52d88 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -9,6 +9,7 @@ #include <linux/types.h> #include <linux/list.h> #include <linux/sysfs.h> +#include <linux/rwsem.h> #include <asm/atomic.h> struct kobject { @@ -16,6 +17,7 @@ struct kobject { atomic_t refcount; struct list_head entry; struct kobject * parent; + struct subsystem * subsys; struct sysfs_dir dir; }; @@ -27,4 +29,28 @@ extern void kobject_unregister(struct kobject *); extern struct kobject * kobject_get(struct kobject *); extern void kobject_put(struct kobject *); + +struct subsystem { + struct kobject kobj; + struct list_head list; + struct rw_semaphore rwsem; + struct subsystem * parent; + void (*release)(struct kobject *); + struct sysfs_ops * sysfs_ops; +}; + +extern void subsystem_init(struct subsystem *); +extern int subsystem_register(struct subsystem *); +extern void subsystem_unregister(struct subsystem *); + +static inline struct subsystem * subsys_get(struct subsystem * s) +{ + return container_of(kobject_get(&s->kobj),struct subsystem,kobj); +} + +static inline void subsys_put(struct subsystem * s) +{ + kobject_put(&s->kobj); +} + #endif /* _KOBJECT_H_ */ |
