summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/bus.c23
-rw-r--r--drivers/base/core.c22
-rw-r--r--drivers/base/driver.c22
3 files changed, 6 insertions, 61 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 5ee5d3c1d74b..f099af0b41af 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -884,32 +884,13 @@ static void bus_remove_attrs(struct bus_type *bus)
static int bus_add_groups(struct bus_type *bus,
const struct attribute_group **groups)
{
- int error = 0;
- int i;
-
- if (groups) {
- for (i = 0; groups[i]; i++) {
- error = sysfs_create_group(&bus->p->subsys.kobj,
- groups[i]);
- if (error) {
- while (--i >= 0)
- sysfs_remove_group(&bus->p->subsys.kobj,
- groups[i]);
- break;
- }
- }
- }
- return error;
+ return sysfs_create_groups(&bus->p->subsys.kobj, groups);
}
static void bus_remove_groups(struct bus_type *bus,
const struct attribute_group **groups)
{
- int i;
-
- if (groups)
- for (i = 0; groups[i]; i++)
- sysfs_remove_group(&bus->p->subsys.kobj, groups[i]);
+ sysfs_remove_groups(&bus->p->subsys.kobj, groups);
}
static void klist_devices_get(struct klist_node *n)
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)
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 89db726ebb98..c7efccb6f3bb 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -126,31 +126,13 @@ EXPORT_SYMBOL_GPL(driver_remove_file);
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);
}
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);
}
/**