diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-12 16:40:20 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-12 16:40:20 -0400 |
commit | dc690d8ef842b464f1c429a376ca16cb8dbee6ae (patch) | |
tree | 77955849af5a15755f5e55e24ae4b9c520583a72 /fs/sysfs/group.c | |
parent | 57399ec9077a4b962b81037aaa279fab52f5e989 (diff) | |
parent | 91a6902958f052358899f58683d44e36228d85c2 (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6: (61 commits)
sysfs: add parameter "struct bin_attribute *" in .read/.write methods for sysfs binary attributes
sysfs: make directory dentries and inodes reclaimable
sysfs: implement sysfs_get_dentry()
sysfs: move sysfs_drop_dentry() to dir.c and make it static
sysfs: restructure add/remove paths and fix inode update
sysfs: use sysfs_mutex to protect the sysfs_dirent tree
sysfs: consolidate sysfs spinlocks
sysfs: make kobj point to sysfs_dirent instead of dentry
sysfs: implement sysfs_find_dirent() and sysfs_get_dirent()
sysfs: implement SYSFS_FLAG_REMOVED flag
sysfs: rename sysfs_dirent->s_type to s_flags and make room for flags
sysfs: make sysfs_drop_dentry() access inodes using ilookup()
sysfs: Fix oops in sysfs_drop_dentry on x86_64
sysfs: use singly-linked list for sysfs_dirent tree
sysfs: slim down sysfs_dirent->s_active
sysfs: move s_active functions to fs/sysfs/dir.c
sysfs: fix root sysfs_dirent -> root dentry association
sysfs: use iget_locked() instead of new_inode()
sysfs: reorganize sysfs_new_indoe() and sysfs_create()
sysfs: fix parent refcounting during rename and move
...
Diffstat (limited to 'fs/sysfs/group.c')
-rw-r--r-- | fs/sysfs/group.c | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index 52eed2a7a5ef..f318b73c790c 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c | |||
@@ -18,26 +18,25 @@ | |||
18 | #include "sysfs.h" | 18 | #include "sysfs.h" |
19 | 19 | ||
20 | 20 | ||
21 | static void remove_files(struct dentry * dir, | 21 | static void remove_files(struct sysfs_dirent *dir_sd, |
22 | const struct attribute_group * grp) | 22 | const struct attribute_group *grp) |
23 | { | 23 | { |
24 | struct attribute *const* attr; | 24 | struct attribute *const* attr; |
25 | 25 | ||
26 | for (attr = grp->attrs; *attr; attr++) | 26 | for (attr = grp->attrs; *attr; attr++) |
27 | sysfs_hash_and_remove(dir,(*attr)->name); | 27 | sysfs_hash_and_remove(dir_sd, (*attr)->name); |
28 | } | 28 | } |
29 | 29 | ||
30 | static int create_files(struct dentry * dir, | 30 | static int create_files(struct sysfs_dirent *dir_sd, |
31 | const struct attribute_group * grp) | 31 | const struct attribute_group *grp) |
32 | { | 32 | { |
33 | struct attribute *const* attr; | 33 | struct attribute *const* attr; |
34 | int error = 0; | 34 | int error = 0; |
35 | 35 | ||
36 | for (attr = grp->attrs; *attr && !error; attr++) { | 36 | for (attr = grp->attrs; *attr && !error; attr++) |
37 | error = sysfs_add_file(dir, *attr, SYSFS_KOBJ_ATTR); | 37 | error = sysfs_add_file(dir_sd, *attr, SYSFS_KOBJ_ATTR); |
38 | } | ||
39 | if (error) | 38 | if (error) |
40 | remove_files(dir,grp); | 39 | remove_files(dir_sd, grp); |
41 | return error; | 40 | return error; |
42 | } | 41 | } |
43 | 42 | ||
@@ -45,44 +44,44 @@ static int create_files(struct dentry * dir, | |||
45 | int sysfs_create_group(struct kobject * kobj, | 44 | int sysfs_create_group(struct kobject * kobj, |
46 | const struct attribute_group * grp) | 45 | const struct attribute_group * grp) |
47 | { | 46 | { |
48 | struct dentry * dir; | 47 | struct sysfs_dirent *sd; |
49 | int error; | 48 | int error; |
50 | 49 | ||
51 | BUG_ON(!kobj || !kobj->dentry); | 50 | BUG_ON(!kobj || !kobj->sd); |
52 | 51 | ||
53 | if (grp->name) { | 52 | if (grp->name) { |
54 | error = sysfs_create_subdir(kobj,grp->name,&dir); | 53 | error = sysfs_create_subdir(kobj, grp->name, &sd); |
55 | if (error) | 54 | if (error) |
56 | return error; | 55 | return error; |
57 | } else | 56 | } else |
58 | dir = kobj->dentry; | 57 | sd = kobj->sd; |
59 | dir = dget(dir); | 58 | sysfs_get(sd); |
60 | if ((error = create_files(dir,grp))) { | 59 | error = create_files(sd, grp); |
60 | if (error) { | ||
61 | if (grp->name) | 61 | if (grp->name) |
62 | sysfs_remove_subdir(dir); | 62 | sysfs_remove_subdir(sd); |
63 | } | 63 | } |
64 | dput(dir); | 64 | sysfs_put(sd); |
65 | return error; | 65 | return error; |
66 | } | 66 | } |
67 | 67 | ||
68 | void sysfs_remove_group(struct kobject * kobj, | 68 | void sysfs_remove_group(struct kobject * kobj, |
69 | const struct attribute_group * grp) | 69 | const struct attribute_group * grp) |
70 | { | 70 | { |
71 | struct dentry * dir; | 71 | struct sysfs_dirent *dir_sd = kobj->sd; |
72 | struct sysfs_dirent *sd; | ||
72 | 73 | ||
73 | if (grp->name) { | 74 | if (grp->name) { |
74 | dir = lookup_one_len_kern(grp->name, kobj->dentry, | 75 | sd = sysfs_get_dirent(dir_sd, grp->name); |
75 | strlen(grp->name)); | 76 | BUG_ON(!sd); |
76 | BUG_ON(IS_ERR(dir)); | 77 | } else |
77 | } | 78 | sd = sysfs_get(dir_sd); |
78 | else | ||
79 | dir = dget(kobj->dentry); | ||
80 | 79 | ||
81 | remove_files(dir,grp); | 80 | remove_files(sd, grp); |
82 | if (grp->name) | 81 | if (grp->name) |
83 | sysfs_remove_subdir(dir); | 82 | sysfs_remove_subdir(sd); |
84 | /* release the ref. taken in this routine */ | 83 | |
85 | dput(dir); | 84 | sysfs_put(sd); |
86 | } | 85 | } |
87 | 86 | ||
88 | 87 | ||