diff options
| author | Patrick Mochel <mochel@osdl.org> | 2003-01-05 23:56:06 -0600 |
|---|---|---|
| committer | Patrick Mochel <mochel@osdl.org> | 2003-01-05 23:56:06 -0600 |
| commit | 85e865ecdb545bdd8b650540563528c1d3f6e9af (patch) | |
| tree | ee72feaa12b6296c7587c08f013f6fe4fd4f3d53 /include | |
| parent | 3e815107666d4ee5089661a7125af302797b3e08 (diff) | |
kobjects: Remove kobject::subsys and subsystem::kobj.
The kobject core no longer references a subsystem directly through a kobject,
instead using the kobject's dominant kset to reference the subsystem. The
registrants of kobjects have been fixed up.
To aid in this process, a few helpers were introdcuced:
- kobj_set_kset_s(obj,subsys)
- kset_set_kset_s(obj,subsys)
- subsys_set_kset(obj,subsys)
that set the kset ptr of embedded kobjects for objects that have different
embedded types. See include/linux/kobject.h for more description and usage.
struct subsystem::kobj is also removed, relying solely on a subsystem's
embedded kset for hierarchy information. Since this requires modification
of the subsystem declarations, a helper macro has been defined:
decl_subsys(name,type)
which initializes the name and ktype fields of the subsystem's embedded
kset. All the subsystem declarations have been fixed up.
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/device.h | 2 | ||||
| -rw-r--r-- | include/linux/kobject.h | 54 |
2 files changed, 53 insertions, 3 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index ed58edf544f0..998ca9a08299 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -212,7 +212,7 @@ struct device_interface { char * name; struct device_class * devclass; - struct subsystem subsys; + struct kset kset; u32 devnum; int (*add_device) (struct device *); diff --git a/include/linux/kobject.h b/include/linux/kobject.h index ac17f05cb1ff..2b9f1321a54e 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -19,7 +19,6 @@ struct kobject { atomic_t refcount; struct list_head entry; struct kobject * parent; - struct subsystem * subsys; struct kset * kset; struct kobj_type * ktype; struct dentry * dentry; @@ -90,11 +89,62 @@ static inline void kset_put(struct kset * k) struct subsystem { struct kset kset; - struct kobject kobj; struct rw_semaphore rwsem; }; +#define decl_subsys(_name,_type) \ +struct subsystem _name##_subsys = { \ + .kset = { \ + .kobj = { .name = __stringify(_name) }, \ + .ktype = _type, \ + } \ +} + + +/** + * Helpers for setting the kset of registered objects. + * Often, a registered object belongs to a kset embedded in a + * subsystem. These do no magic, just make the resulting code + * easier to follow. + */ + +/** + * kobj_set_kset_s(obj,subsys) - set kset for embedded kobject. + * @obj: ptr to some object type. + * @subsys: a subsystem object (not a ptr). + * + * Can be used for any object type with an embedded ->kobj. + */ + +#define kobj_set_kset_s(obj,subsys) \ + (obj)->kobj.kset = &(subsys).kset + +/** + * kset_set_kset_s(obj,subsys) - set kset for embedded kset. + * @obj: ptr to some object type. + * @subsys: a subsystem object (not a ptr). + * + * Can be used for any object type with an embedded ->kset. + * Sets the kset of @obj's embedded kobject (via its embedded + * kset) to @subsys.kset. This makes @obj a member of that + * kset. + */ + +#define kset_set_kset_s(obj,subsys) \ + (obj)->kset.kobj.kset = &(subsys).kset + +/** + * subsys_set_kset(obj,subsys) - set kset for subsystem + * @obj: ptr to some object type. + * @subsys: a subsystem object (not a ptr). + * + * Can be used for any object type with an embedded ->subsys. + * Sets the kset of @obj's kobject to @subsys.kset. This makes + * the object a member of that kset. + */ +#define subsys_set_kset(obj,_subsys) \ + (obj)->subsys.kset.kobj.kset = &(_subsys).kset extern void subsystem_init(struct subsystem *); extern int subsystem_register(struct subsystem *); |
