diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-11-28 16:41:41 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-11-29 21:12:12 +0100 |
commit | ced6473e7486702f530a49f886b73195e4977734 (patch) | |
tree | f4622f9caeccd1c86f340a86508287ff68670a1d /drivers/base/class.c | |
parent | kernfs: Declare two local data structures static (diff) | |
download | linux-ced6473e7486702f530a49f886b73195e4977734.tar.xz linux-ced6473e7486702f530a49f886b73195e4977734.zip |
driver core: class: add class_groups support
struct class needs to have a set of default groups that are added, as
adding individual attributes does not work well in the long run. So add
support for that.
Future patches will convert the existing usages of class_attrs to use
class_groups and then class_attrs will go away.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/class.c')
-rw-r--r-- | drivers/base/class.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c index 71059e32bebc..a2b2896693d6 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -163,6 +163,18 @@ static void klist_class_dev_put(struct klist_node *n) put_device(dev); } +static int class_add_groups(struct class *cls, + const struct attribute_group **groups) +{ + return sysfs_create_groups(&cls->p->subsys.kobj, groups); +} + +static void class_remove_groups(struct class *cls, + const struct attribute_group **groups) +{ + return sysfs_remove_groups(&cls->p->subsys.kobj, groups); +} + int __class_register(struct class *cls, struct lock_class_key *key) { struct subsys_private *cp; @@ -203,6 +215,8 @@ int __class_register(struct class *cls, struct lock_class_key *key) kfree(cp); return error; } + error = class_add_groups(class_get(cls), cls->class_groups); + class_put(cls); error = add_class_attrs(class_get(cls)); class_put(cls); return error; @@ -213,6 +227,7 @@ void class_unregister(struct class *cls) { pr_debug("device class '%s': unregistering\n", cls->name); remove_class_attrs(cls); + class_remove_groups(cls, cls->class_groups); kset_unregister(&cls->p->subsys); } |