diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-21 13:47:50 -0700 |
---|---|---|
committer | Maciej Wereski <m.wereski@partner.samsung.com> | 2015-06-09 11:31:01 +0200 |
commit | e72185c6ba52e77647eda0abb8b644fc98097580 (patch) | |
tree | 06952440d206dab174a3eaf21a785192f8443b7e /drivers | |
parent | 2f7f9d88c63d78ff69071732275b5ef282a6b3a4 (diff) | |
download | linux-3.10-e72185c6ba52e77647eda0abb8b644fc98097580.tar.gz linux-3.10-e72185c6ba52e77647eda0abb8b644fc98097580.tar.bz2 linux-3.10-e72185c6ba52e77647eda0abb8b644fc98097580.zip |
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')
-rw-r--r-- | drivers/base/core.c | 22 | ||||
-rw-r--r-- | drivers/base/driver.c | 22 |
2 files changed, 4 insertions, 40 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index 2a19097a7cb..00a3be583c0 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -464,31 +464,13 @@ static void device_remove_bin_attributes(struct device *dev, static 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); } static 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) diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 974e301a1ef..4a991167da9 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -126,31 +126,13 @@ EXPORT_SYMBOL_GPL(driver_remove_file); static int driver_add_groups(struct device_driver *drv, const struct attribute_group **groups) { - int error = 0; - int i; - - if (groups) { - for (i = 0; groups[i]; i++) { - error = sysfs_create_group(&drv->p->kobj, groups[i]); - if (error) { - while (--i >= 0) - sysfs_remove_group(&drv->p->kobj, - groups[i]); - break; - } - } - } - return error; + return sysfs_create_groups(&drv->p->kobj, groups); } static void driver_remove_groups(struct device_driver *drv, const struct attribute_group **groups) { - int i; - - if (groups) - for (i = 0; groups[i]; i++) - sysfs_remove_group(&drv->p->kobj, groups[i]); + sysfs_remove_groups(&drv->p->kobj, groups); } /** |