diff options
author | Tejun Heo <htejun@gmail.com> | 2007-08-02 08:38:03 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-12 17:51:03 -0400 |
commit | 41fc1c27452e041a18e5141b8203ee0ea72bc483 (patch) | |
tree | fc81138ca37182c25931818681630c90b018b127 /fs/sysfs/inode.c | |
parent | ff869de7bf5e76adffebd3a176c1c73bca7eddb7 (diff) |
sysfs: make sysfs_add/remove_one() call link/unlink_sibling() implictly
When adding or removing a sysfs_dirent, the user used to be required
to call link/unlink separately. It was for two reasons - code looked
like that before sysfs_addrm_cxt conversion and to avoid looping
through parent_sd->children list twice during removal.
Performance optimization during removal just isn't worth it. Make
sysfs_add/remove_one() call sysfs_link/unlink_sibing() implicitly.
This makes code simpler albeit slightly less efficient. This change
doesn't introduce any noticeable behavior change.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs/inode.c')
-rw-r--r-- | fs/sysfs/inode.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c index 45128b79bc68..efb4062fe099 100644 --- a/fs/sysfs/inode.c +++ b/fs/sysfs/inode.c | |||
@@ -189,25 +189,16 @@ void sysfs_instantiate(struct dentry *dentry, struct inode *inode) | |||
189 | int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name) | 189 | int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name) |
190 | { | 190 | { |
191 | struct sysfs_addrm_cxt acxt; | 191 | struct sysfs_addrm_cxt acxt; |
192 | struct sysfs_dirent **pos, *sd; | 192 | struct sysfs_dirent *sd; |
193 | 193 | ||
194 | if (!dir_sd) | 194 | if (!dir_sd) |
195 | return -ENOENT; | 195 | return -ENOENT; |
196 | 196 | ||
197 | sysfs_addrm_start(&acxt, dir_sd); | 197 | sysfs_addrm_start(&acxt, dir_sd); |
198 | 198 | ||
199 | for (pos = &dir_sd->s_children; *pos; pos = &(*pos)->s_sibling) { | 199 | sd = sysfs_find_dirent(dir_sd, name); |
200 | sd = *pos; | 200 | if (sd) |
201 | 201 | sysfs_remove_one(&acxt, sd); | |
202 | if (!sysfs_type(sd)) | ||
203 | continue; | ||
204 | if (!strcmp(sd->s_name, name)) { | ||
205 | *pos = sd->s_sibling; | ||
206 | sd->s_sibling = NULL; | ||
207 | sysfs_remove_one(&acxt, sd); | ||
208 | break; | ||
209 | } | ||
210 | } | ||
211 | 202 | ||
212 | if (sysfs_addrm_finish(&acxt)) | 203 | if (sysfs_addrm_finish(&acxt)) |
213 | return 0; | 204 | return 0; |