diff options
| author | Patrick Mochel <mochel@osdl.org> | 2003-01-04 00:06:27 -0600 |
|---|---|---|
| committer | Patrick Mochel <mochel@osdl.org> | 2003-01-04 00:06:27 -0600 |
| commit | 23066070bb05cdf6fc94af43ca8f444bc293f93e (patch) | |
| tree | a322b17406a1c0191edb143c86593ba71dee9661 /lib/kobject.c | |
| parent | 509b39b15356d2cebf7ed9e709561eb7c5a59759 (diff) | |
kobject: Introduce struct kobj_type.
This is the first step in morphing struct subsystem into something meaningful.
A subsystem is defined simply as a list of kobjects of a certain type, which
is far too generic. A subsystem should be representative of a large entity
of code (i.e. a subsystem of the kernel), not just a simple list.
This changeset:
- Creates struct kobj_type, a descriptor of the type a kobject is embedded
in.
- Extracts the fields that are specific to a particular object type from
struct subsystem and puts them in struct kobj_type, which are
- the object's release method.
- the sysfs operations for the object type.
- the default attributes of the object type.
- Adds ptr to struct kobject to point to its type descriptor.
- Converts the existing subsystem definitions to define struct kobj_type.
struct kobj_type's are not registered, as they do not have any explicit
representation in the object hierarchy, nor do they have any fields that
need runtime initialization.
A kobject's ktype should be set when it is registered, like its subsystem.
Note this obviates the need for defining a struct subsystem when an object
type does not need to be kept in a global list.
Diffstat (limited to 'lib/kobject.c')
| -rw-r--r-- | lib/kobject.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/kobject.c b/lib/kobject.c index 24807bc72f81..f2f38b092a6a 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -25,13 +25,13 @@ static spinlock_t kobj_lock = SPIN_LOCK_UNLOCKED; static int populate_dir(struct kobject * kobj) { - struct subsystem * s = kobj->subsys; + struct kobj_type * t = kobj->ktype; struct attribute * attr; int error = 0; int i; - if (s && s->default_attrs) { - for (i = 0; (attr = s->default_attrs[i]); i++) { + if (t && t->default_attrs) { + for (i = 0; (attr = t->default_attrs[i]); i++) { if ((error = sysfs_create_file(kobj,attr))) break; } @@ -173,17 +173,18 @@ struct kobject * kobject_get(struct kobject * kobj) void kobject_cleanup(struct kobject * kobj) { + struct kobj_type * t = kobj->ktype; struct subsystem * s = kobj->subsys; pr_debug("kobject %s: cleaning up\n",kobj->name); if (s) { down_write(&s->rwsem); list_del_init(&kobj->entry); - if (s->release) - s->release(kobj); up_write(&s->rwsem); subsys_put(s); } + if (t && t->release) + t->release(kobj); } /** |
