aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs/inode.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-06-13 14:45:15 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-07-11 19:09:04 -0400
commit0c096b507f15397da890051ee73de4266d3941fb (patch)
treec6b7d204a493157b3926bdb46500313eee9f9690 /fs/sysfs/inode.c
parent13b3086d2ea483cbcae5a4236446cecc082a72cf (diff)
sysfs: add sysfs_dirent->s_name
Add s_name to sysfs_dirent. This is to further reduce dependency to the associated dentry. Name is copied for directories and symlinks but not for attributes. Where possible, name dereferences are converted to use sd->s_name. sysfs_symlink->link_name and sysfs_get_name() are unused now and removed. This change allows symlink to be implemented using sysfs_dirent tree proper, which is the last remaining dentry-dependent sysfs walk. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs/inode.c')
-rw-r--r--fs/sysfs/inode.c33
1 files changed, 1 insertions, 32 deletions
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 5266eec15f6e..5c605b0003a8 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -191,37 +191,6 @@ int sysfs_create(struct dentry * dentry, int mode, int (*init)(struct inode *))
191 return error; 191 return error;
192} 192}
193 193
194/*
195 * Get the name for corresponding element represented by the given sysfs_dirent
196 */
197const unsigned char * sysfs_get_name(struct sysfs_dirent *sd)
198{
199 struct attribute * attr;
200 struct bin_attribute * bin_attr;
201 struct sysfs_symlink * sl;
202
203 BUG_ON(!sd || !sd->s_element);
204
205 switch (sd->s_type) {
206 case SYSFS_DIR:
207 /* Always have a dentry so use that */
208 return sd->s_dentry->d_name.name;
209
210 case SYSFS_KOBJ_ATTR:
211 attr = sd->s_element;
212 return attr->name;
213
214 case SYSFS_KOBJ_BIN_ATTR:
215 bin_attr = sd->s_element;
216 return bin_attr->attr.name;
217
218 case SYSFS_KOBJ_LINK:
219 sl = sd->s_element;
220 return sl->link_name;
221 }
222 return NULL;
223}
224
225static inline void orphan_all_buffers(struct inode *node) 194static inline void orphan_all_buffers(struct inode *node)
226{ 195{
227 struct sysfs_buffer_collection *set; 196 struct sysfs_buffer_collection *set;
@@ -305,7 +274,7 @@ int sysfs_hash_and_remove(struct dentry * dir, const char * name)
305 list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { 274 list_for_each_entry(sd, &parent_sd->s_children, s_sibling) {
306 if (!sd->s_element) 275 if (!sd->s_element)
307 continue; 276 continue;
308 if (!strcmp(sysfs_get_name(sd), name)) { 277 if (!strcmp(sd->s_name, name)) {
309 list_del_init(&sd->s_sibling); 278 list_del_init(&sd->s_sibling);
310 sysfs_drop_dentry(sd, dir); 279 sysfs_drop_dentry(sd, dir);
311 sysfs_put(sd); 280 sysfs_put(sd);