diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-21 22:47:50 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-22 01:02:19 +0200 |
commit | 3e9b2bae8369661070622d05570cbcdfa01770e6 (patch) | |
tree | a5e22d5953306740dca0da253752ad6830baaa50 /drivers/base/bus.c | |
parent | drivers: base: use standard device online/offline for state change (diff) | |
download | linux-3e9b2bae8369661070622d05570cbcdfa01770e6.tar.xz linux-3e9b2bae8369661070622d05570cbcdfa01770e6.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/base/bus.c')
-rw-r--r-- | drivers/base/bus.c | 23 |
1 files changed, 2 insertions, 21 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) |