Commit e6289147 authored by Patrick Mochel's avatar Patrick Mochel

[sysfs] Convert struct attribute_group to take array of pointers.

From Stephen Hemminger. Needed to use attribute groups effectively.
 
parent df3e1207
...@@ -17,20 +17,20 @@ ...@@ -17,20 +17,20 @@
static void remove_files(struct dentry * dir, struct attribute_group * grp) static void remove_files(struct dentry * dir, struct attribute_group * grp)
{ {
struct attribute * attr; struct attribute ** attr;
for (attr = grp->attrs; attr->name; attr++) for (attr = grp->attrs; *attr; attr++)
sysfs_hash_and_remove(dir,attr->name); sysfs_hash_and_remove(dir,(*attr)->name);
} }
static int create_files(struct kobject * kobj, struct dentry * dir, static int create_files(struct dentry * dir,
struct attribute_group * grp) struct attribute_group * grp)
{ {
struct attribute * attr; struct attribute ** attr;
int error = 0; int error = 0;
for (attr = grp->attrs; attr->name && !error; attr++) { for (attr = grp->attrs; *attr && !error; attr++) {
error = sysfs_add_file(dir,attr); error = sysfs_add_file(dir,*attr);
} }
if (error) if (error)
remove_files(dir,grp); remove_files(dir,grp);
...@@ -50,7 +50,7 @@ int sysfs_create_group(struct kobject * kobj, struct attribute_group * grp) ...@@ -50,7 +50,7 @@ int sysfs_create_group(struct kobject * kobj, struct attribute_group * grp)
} else } else
dir = kobj->dentry; dir = kobj->dentry;
dir = dget(dir); dir = dget(dir);
if ((error = create_files(kobj,dir,grp))) { if ((error = create_files(dir,grp))) {
if (grp->name) if (grp->name)
sysfs_remove_subdir(dir); sysfs_remove_subdir(dir);
dput(dir); dput(dir);
......
...@@ -60,7 +60,7 @@ sysfs_remove_link(struct kobject *, char * name); ...@@ -60,7 +60,7 @@ sysfs_remove_link(struct kobject *, char * name);
struct attribute_group { struct attribute_group {
char * name; char * name;
struct attribute * attrs; struct attribute ** attrs;
}; };
int sysfs_create_group(struct kobject *, struct attribute_group *); int sysfs_create_group(struct kobject *, struct attribute_group *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment