diff options
author | Patrick Mochel <mochel@osdl.org> | 2002-11-21 05:01:54 -0600 |
---|---|---|
committer | Patrick Mochel <mochel@osdl.org> | 2002-11-21 05:01:54 -0600 |
commit | 2ce5e0bca93f06683b40fbae3b5b4031dd02b2cc (patch) | |
tree | 2e78098397fe7fc73b295bddec57872b397b0bc9 /lib | |
parent | 35551cf5753fe89869f24fc06f6b787b02a10acc (diff) | |
download | history-2ce5e0bca93f06683b40fbae3b5b4031dd02b2cc.tar.gz |
Allow subsystem to have attributes, too.
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).
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kobject.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/kobject.c b/lib/kobject.c index 33e4f8c9ce58c3..bdf6636d2b2ed9 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -229,6 +229,38 @@ void subsystem_unregister(struct subsystem * s) } +/** + * subsystem_create_file - export sysfs attribute file. + * @s: subsystem. + * @a: subsystem attribute descriptor. + */ + +int subsys_create_file(struct subsystem * s, struct subsys_attribute * a) +{ + int error = 0; + if (subsys_get(s)) { + error = sysfs_create_file(&s->kobj,&a->attr); + subsys_put(s); + } + return error; +} + + +/** + * subsystem_remove_file - remove sysfs attribute file. + * @s: subsystem. + * @a: attribute desciptor. + */ + +void subsys_remove_file(struct subsystem * s, struct subsys_attribute * a) +{ + if (subsys_get(s)) { + sysfs_remove_file(&s->kobj,&a->attr); + subsys_put(s); + } +} + + EXPORT_SYMBOL(kobject_init); EXPORT_SYMBOL(kobject_register); EXPORT_SYMBOL(kobject_unregister); @@ -238,3 +270,5 @@ EXPORT_SYMBOL(kobject_put); EXPORT_SYMBOL(subsystem_init); EXPORT_SYMBOL(subsystem_register); EXPORT_SYMBOL(subsystem_unregister); +EXPORT_SYMBOL(subsys_create_file); +EXPORT_SYMBOL(subsys_remove_file); |