aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs/symlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/sysfs/symlink.c')
-rw-r--r--fs/sysfs/symlink.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index 45b62e229627..43cc5222f136 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -66,7 +66,6 @@ static int sysfs_add_link(struct sysfs_dirent * parent_sd, const char * name,
66 */ 66 */
67int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name) 67int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name)
68{ 68{
69 struct dentry *dentry = NULL;
70 struct sysfs_dirent *parent_sd = NULL; 69 struct sysfs_dirent *parent_sd = NULL;
71 struct sysfs_dirent *target_sd = NULL; 70 struct sysfs_dirent *target_sd = NULL;
72 int error = -EEXIST; 71 int error = -EEXIST;
@@ -75,29 +74,28 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char
75 74
76 if (!kobj) { 75 if (!kobj) {
77 if (sysfs_mount && sysfs_mount->mnt_sb) 76 if (sysfs_mount && sysfs_mount->mnt_sb)
78 dentry = sysfs_mount->mnt_sb->s_root; 77 parent_sd = sysfs_mount->mnt_sb->s_root->d_fsdata;
79 } else 78 } else
80 dentry = kobj->dentry; 79 parent_sd = kobj->sd;
81 80
82 if (!dentry) 81 if (!parent_sd)
83 return -EFAULT; 82 return -EFAULT;
84 parent_sd = dentry->d_fsdata;
85 83
86 /* target->dentry can go away beneath us but is protected with 84 /* target->sd can go away beneath us but is protected with
87 * kobj_sysfs_assoc_lock. Fetch target_sd from it. 85 * kobj_sysfs_assoc_lock. Fetch target_sd from it.
88 */ 86 */
89 spin_lock(&kobj_sysfs_assoc_lock); 87 spin_lock(&kobj_sysfs_assoc_lock);
90 if (target->dentry) 88 if (target->sd)
91 target_sd = sysfs_get(target->dentry->d_fsdata); 89 target_sd = sysfs_get(target->sd);
92 spin_unlock(&kobj_sysfs_assoc_lock); 90 spin_unlock(&kobj_sysfs_assoc_lock);
93 91
94 if (!target_sd) 92 if (!target_sd)
95 return -ENOENT; 93 return -ENOENT;
96 94
97 mutex_lock(&dentry->d_inode->i_mutex); 95 mutex_lock(&parent_sd->s_dentry->d_inode->i_mutex);
98 if (!sysfs_find_dirent(dentry->d_fsdata, name)) 96 if (!sysfs_find_dirent(parent_sd, name))
99 error = sysfs_add_link(parent_sd, name, target_sd); 97 error = sysfs_add_link(parent_sd, name, target_sd);
100 mutex_unlock(&dentry->d_inode->i_mutex); 98 mutex_unlock(&parent_sd->s_dentry->d_inode->i_mutex);
101 99
102 if (error) 100 if (error)
103 sysfs_put(target_sd); 101 sysfs_put(target_sd);
@@ -114,7 +112,7 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char
114 112
115void sysfs_remove_link(struct kobject * kobj, const char * name) 113void sysfs_remove_link(struct kobject * kobj, const char * name)
116{ 114{
117 sysfs_hash_and_remove(kobj->dentry,name); 115 sysfs_hash_and_remove(kobj->sd, name);
118} 116}
119 117
120static int sysfs_get_target_path(struct sysfs_dirent * parent_sd, 118static int sysfs_get_target_path(struct sysfs_dirent * parent_sd,