aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs/symlink.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-12-11 14:11:53 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-11 18:28:36 -0500
commit324a56e16e44baecac3ca799fd216154145c14bf (patch)
tree4fb43421bfe884cf4e245e3a4672295bae4c7bd9 /fs/sysfs/symlink.c
parenta8b1c0193602b7ecdeaa7aa8c15c9c3da33244c8 (diff)
kernfs: s/sysfs_dirent/kernfs_node/ and rename its friends accordingly
kernfs has just been separated out from sysfs and we're already in full conflict mode. Nothing can make the situation any worse. Let's take the chance to name things properly. This patch performs the following renames. * s/sysfs_elem_dir/kernfs_elem_dir/ * s/sysfs_elem_symlink/kernfs_elem_symlink/ * s/sysfs_elem_attr/kernfs_elem_file/ * s/sysfs_dirent/kernfs_node/ * s/sd/kn/ in kernfs proper * s/parent_sd/parent/ * s/target_sd/target/ * s/dir_sd/parent/ * s/to_sysfs_dirent()/rb_to_kn()/ * misc renames of local vars when they conflict with the above Because md, mic and gpio dig into sysfs details, this patch ends up modifying them. All are sysfs_dirent renames and trivial. While we can avoid these by introducing a dummy wrapping struct sysfs_dirent around kernfs_node, given the limited usage outside kernfs and sysfs proper, I don't think such workaround is called for. This patch is strictly rename only and doesn't introduce any functional difference. - mic / gpio renames were missing. Spotted by kbuild test robot. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Neil Brown <neilb@suse.de> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Ashutosh Dixit <ashutosh.dixit@intel.com> Cc: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/sysfs/symlink.c')
-rw-r--r--fs/sysfs/symlink.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index 1b8c9ed8511a..4ed3d49ad279 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -18,66 +18,66 @@
18 18
19#include "sysfs.h" 19#include "sysfs.h"
20 20
21static int sysfs_do_create_link_sd(struct sysfs_dirent *parent_sd, 21static int sysfs_do_create_link_sd(struct kernfs_node *parent,
22 struct kobject *target, 22 struct kobject *target_kobj,
23 const char *name, int warn) 23 const char *name, int warn)
24{ 24{
25 struct sysfs_dirent *sd, *target_sd = NULL; 25 struct kernfs_node *kn, *target = NULL;
26 26
27 BUG_ON(!name || !parent_sd); 27 BUG_ON(!name || !parent);
28 28
29 /* 29 /*
30 * We don't own @target and it may be removed at any time. 30 * We don't own @target_kobj and it may be removed at any time.
31 * Synchronize using sysfs_symlink_target_lock. See 31 * Synchronize using sysfs_symlink_target_lock. See
32 * sysfs_remove_dir() for details. 32 * sysfs_remove_dir() for details.
33 */ 33 */
34 spin_lock(&sysfs_symlink_target_lock); 34 spin_lock(&sysfs_symlink_target_lock);
35 if (target->sd) { 35 if (target_kobj->sd) {
36 target_sd = target->sd; 36 target = target_kobj->sd;
37 kernfs_get(target_sd); 37 kernfs_get(target);
38 } 38 }
39 spin_unlock(&sysfs_symlink_target_lock); 39 spin_unlock(&sysfs_symlink_target_lock);
40 40
41 if (!target_sd) 41 if (!target)
42 return -ENOENT; 42 return -ENOENT;
43 43
44 sd = kernfs_create_link(parent_sd, name, target_sd); 44 kn = kernfs_create_link(parent, name, target);
45 kernfs_put(target_sd); 45 kernfs_put(target);
46 46
47 if (!IS_ERR(sd)) 47 if (!IS_ERR(kn))
48 return 0; 48 return 0;
49 49
50 if (warn && PTR_ERR(sd) == -EEXIST) 50 if (warn && PTR_ERR(kn) == -EEXIST)
51 sysfs_warn_dup(parent_sd, name); 51 sysfs_warn_dup(parent, name);
52 return PTR_ERR(sd); 52 return PTR_ERR(kn);
53} 53}
54 54
55/** 55/**
56 * sysfs_create_link_sd - create symlink to a given object. 56 * sysfs_create_link_sd - create symlink to a given object.
57 * @sd: directory we're creating the link in. 57 * @kn: directory we're creating the link in.
58 * @target: object we're pointing to. 58 * @target: object we're pointing to.
59 * @name: name of the symlink. 59 * @name: name of the symlink.
60 */ 60 */
61int sysfs_create_link_sd(struct sysfs_dirent *sd, struct kobject *target, 61int sysfs_create_link_sd(struct kernfs_node *kn, struct kobject *target,
62 const char *name) 62 const char *name)
63{ 63{
64 return sysfs_do_create_link_sd(sd, target, name, 1); 64 return sysfs_do_create_link_sd(kn, target, name, 1);
65} 65}
66 66
67static int sysfs_do_create_link(struct kobject *kobj, struct kobject *target, 67static int sysfs_do_create_link(struct kobject *kobj, struct kobject *target,
68 const char *name, int warn) 68 const char *name, int warn)
69{ 69{
70 struct sysfs_dirent *parent_sd = NULL; 70 struct kernfs_node *parent = NULL;
71 71
72 if (!kobj) 72 if (!kobj)
73 parent_sd = sysfs_root_sd; 73 parent = sysfs_root_kn;
74 else 74 else
75 parent_sd = kobj->sd; 75 parent = kobj->sd;
76 76
77 if (!parent_sd) 77 if (!parent)
78 return -EFAULT; 78 return -EFAULT;
79 79
80 return sysfs_do_create_link_sd(parent_sd, target, name, warn); 80 return sysfs_do_create_link_sd(parent, target, name, warn);
81} 81}
82 82
83/** 83/**
@@ -141,14 +141,14 @@ void sysfs_delete_link(struct kobject *kobj, struct kobject *targ,
141 */ 141 */
142void sysfs_remove_link(struct kobject *kobj, const char *name) 142void sysfs_remove_link(struct kobject *kobj, const char *name)
143{ 143{
144 struct sysfs_dirent *parent_sd = NULL; 144 struct kernfs_node *parent = NULL;
145 145
146 if (!kobj) 146 if (!kobj)
147 parent_sd = sysfs_root_sd; 147 parent = sysfs_root_kn;
148 else 148 else
149 parent_sd = kobj->sd; 149 parent = kobj->sd;
150 150
151 kernfs_remove_by_name(parent_sd, name); 151 kernfs_remove_by_name(parent, name);
152} 152}
153EXPORT_SYMBOL_GPL(sysfs_remove_link); 153EXPORT_SYMBOL_GPL(sysfs_remove_link);
154 154
@@ -165,33 +165,33 @@ EXPORT_SYMBOL_GPL(sysfs_remove_link);
165int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *targ, 165int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *targ,
166 const char *old, const char *new, const void *new_ns) 166 const char *old, const char *new, const void *new_ns)
167{ 167{
168 struct sysfs_dirent *parent_sd, *sd = NULL; 168 struct kernfs_node *parent, *kn = NULL;
169 const void *old_ns = NULL; 169 const void *old_ns = NULL;
170 int result; 170 int result;
171 171
172 if (!kobj) 172 if (!kobj)
173 parent_sd = sysfs_root_sd; 173 parent = sysfs_root_kn;
174 else 174 else
175 parent_sd = kobj->sd; 175 parent = kobj->sd;
176 176
177 if (targ->sd) 177 if (targ->sd)
178 old_ns = targ->sd->s_ns; 178 old_ns = targ->sd->s_ns;
179 179
180 result = -ENOENT; 180 result = -ENOENT;
181 sd = kernfs_find_and_get_ns(parent_sd, old, old_ns); 181 kn = kernfs_find_and_get_ns(parent, old, old_ns);
182 if (!sd) 182 if (!kn)
183 goto out; 183 goto out;
184 184
185 result = -EINVAL; 185 result = -EINVAL;
186 if (sysfs_type(sd) != SYSFS_KOBJ_LINK) 186 if (sysfs_type(kn) != SYSFS_KOBJ_LINK)
187 goto out; 187 goto out;
188 if (sd->s_symlink.target_sd->priv != targ) 188 if (kn->s_symlink.target_kn->priv != targ)
189 goto out; 189 goto out;
190 190
191 result = kernfs_rename_ns(sd, parent_sd, new, new_ns); 191 result = kernfs_rename_ns(kn, parent, new, new_ns);
192 192
193out: 193out:
194 kernfs_put(sd); 194 kernfs_put(kn);
195 return result; 195 return result;
196} 196}
197EXPORT_SYMBOL_GPL(sysfs_rename_link_ns); 197EXPORT_SYMBOL_GPL(sysfs_rename_link_ns);