summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndi Kleen <andi@firstfloor.org>2010-01-05 12:48:02 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-08 02:04:47 +0100
commit38457ab3a0d36320370c715145ba6da514127194 (patch)
tree0c3f729c450b18b439dc6ce7a1542d9e8d3dd8e3 /drivers
parentsysfs: Add sysfs_add/remove_files utility functions (diff)
downloadlinux-38457ab3a0d36320370c715145ba6da514127194.tar.xz
linux-38457ab3a0d36320370c715145ba6da514127194.zip
sysfs: Add attribute array to sysdev classes
Add a attribute array that is automatically registered and unregistered to struct sysdev_class. This is similar to what struct class has. A lot of drivers add list of attributes, so it's better to do this easily in the common sysdev layer. This adds a new field to struct sysdev_class. I audited the whole tree and there are no dynamically allocated sysdev classes, so this is fully compatible. Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/sys.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index a38445c0f8c5..747c99e0568b 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -145,13 +145,20 @@ int sysdev_class_register(struct sysdev_class *cls)
if (retval)
return retval;
- return kset_register(&cls->kset);
+ retval = kset_register(&cls->kset);
+ if (!retval && cls->attrs)
+ retval = sysfs_create_files(&cls->kset.kobj,
+ (const struct attribute **)cls->attrs);
+ return retval;
}
void sysdev_class_unregister(struct sysdev_class *cls)
{
pr_debug("Unregistering sysdev class '%s'\n",
kobject_name(&cls->kset.kobj));
+ if (cls->attrs)
+ sysfs_remove_files(&cls->kset.kobj,
+ (const struct attribute **)cls->attrs);
kset_unregister(&cls->kset);
}