Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 77099
b: refs/heads/master
c: d4acd72
h: refs/heads/master
i:
  77097: 9267d28
  77095: faeb050
v: v3
  • Loading branch information
James Bottomley authored and James Bottomley committed Jan 23, 2008
1 parent 41fa4dc commit 66de6df
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d52b3815a52456dcf1a45fbc344e23bb643b2bda
refs/heads/master: d4acd722b7bb5f48b9fc3848e8c2a845b100d84f
26 changes: 16 additions & 10 deletions trunk/fs/sysfs/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,31 @@
#include "sysfs.h"


static void remove_files(struct sysfs_dirent *dir_sd,
static void remove_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
const struct attribute_group *grp)
{
struct attribute *const* attr;
int i;

for (attr = grp->attrs; *attr; attr++)
sysfs_hash_and_remove(dir_sd, (*attr)->name);
for (i = 0, attr = grp->attrs; *attr; i++, attr++)
if (!grp->is_visible ||
grp->is_visible(kobj, *attr, i))
sysfs_hash_and_remove(dir_sd, (*attr)->name);
}

static int create_files(struct sysfs_dirent *dir_sd,
static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
const struct attribute_group *grp)
{
struct attribute *const* attr;
int error = 0;
int error = 0, i;

for (attr = grp->attrs; *attr && !error; attr++)
error = sysfs_add_file(dir_sd, *attr, SYSFS_KOBJ_ATTR);
for (i = 0, attr = grp->attrs; *attr && !error; i++, attr++)
if (!grp->is_visible ||
grp->is_visible(kobj, *attr, i))
error |=
sysfs_add_file(dir_sd, *attr, SYSFS_KOBJ_ATTR);
if (error)
remove_files(dir_sd, grp);
remove_files(dir_sd, kobj, grp);
return error;
}

Expand All @@ -54,7 +60,7 @@ int sysfs_create_group(struct kobject * kobj,
} else
sd = kobj->sd;
sysfs_get(sd);
error = create_files(sd, grp);
error = create_files(sd, kobj, grp);
if (error) {
if (grp->name)
sysfs_remove_subdir(sd);
Expand All @@ -75,7 +81,7 @@ void sysfs_remove_group(struct kobject * kobj,
} else
sd = sysfs_get(dir_sd);

remove_files(sd, grp);
remove_files(sd, kobj, grp);
if (grp->name)
sysfs_remove_subdir(sd);

Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/sysfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ struct attribute {

struct attribute_group {
const char *name;
int (*is_visible)(struct kobject *,
struct attribute *, int);
struct attribute **attrs;
};

Expand Down
2 changes: 1 addition & 1 deletion trunk/kernel/params.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ param_sysfs_setup(struct module_kobject *mk,
sizeof(mp->grp.attrs[0]));
size[1] = (valid_attrs + 1) * sizeof(mp->grp.attrs[0]);

mp = kmalloc(size[0] + size[1], GFP_KERNEL);
mp = kzalloc(size[0] + size[1], GFP_KERNEL);
if (!mp)
return ERR_PTR(-ENOMEM);

Expand Down

0 comments on commit 66de6df

Please sign in to comment.