summaryrefslogtreecommitdiff
path: root/drivers/base/driver.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-22 00:47:50 +0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-22 03:02:19 +0400
commit3e9b2bae8369661070622d05570cbcdfa01770e6 (patch)
treea5e22d5953306740dca0da253752ad6830baaa50 /drivers/base/driver.c
parentfa2be40fe7c0aa3b7accbf6dfa9ef0976e191d4c (diff)
downloadlinux-3e9b2bae8369661070622d05570cbcdfa01770e6.tar.xz
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/driver.c')
-rw-r--r--drivers/base/driver.c22
1 files changed, 2 insertions, 20 deletions
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);
}
/**