diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-21 13:47:50 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-21 16:02:19 -0700 |
commit | 3e9b2bae8369661070622d05570cbcdfa01770e6 (patch) | |
tree | a5e22d5953306740dca0da253752ad6830baaa50 /drivers/base/core.c | |
parent | fa2be40fe7c0aa3b7accbf6dfa9ef0976e191d4c (diff) | |
download | linux-3e9b2bae8369661070622d05570cbcdfa01770e6.tar.bz2 |
sysfs: add sysfs_create/remove_groups()
These functions are being open-coded in 3 different places in the driver
core, and other driver subsystems will want to start doing this as well,
so move it to the sysfs core to keep it all in one place, where we know
it is written properly.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r-- | drivers/base/core.c | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index af646afa5b7e..d743dcee1e77 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -493,31 +493,13 @@ static void device_remove_bin_attributes(struct device *dev, int device_add_groups(struct device *dev, const struct attribute_group **groups) { - int error = 0; - int i; - - if (groups) { - for (i = 0; groups[i]; i++) { - error = sysfs_create_group(&dev->kobj, groups[i]); - if (error) { - while (--i >= 0) - sysfs_remove_group(&dev->kobj, - groups[i]); - break; - } - } - } - return error; + return sysfs_create_groups(&dev->kobj, groups); } void device_remove_groups(struct device *dev, const struct attribute_group **groups) { - int i; - - if (groups) - for (i = 0; groups[i]; i++) - sysfs_remove_group(&dev->kobj, groups[i]); + sysfs_remove_groups(&dev->kobj, groups); } static int device_add_attrs(struct device *dev) |