aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs/dir.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/dir.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/dir.c')
-rw-r--r--fs/sysfs/dir.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 2fea501889e7..f1efe3df0de6 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -21,23 +21,23 @@ DEFINE_SPINLOCK(sysfs_symlink_target_lock);
21 21
22/** 22/**
23 * sysfs_pathname - return full path to sysfs dirent 23 * sysfs_pathname - return full path to sysfs dirent
24 * @sd: sysfs_dirent whose path we want 24 * @kn: kernfs_node whose path we want
25 * @path: caller allocated buffer of size PATH_MAX 25 * @path: caller allocated buffer of size PATH_MAX
26 * 26 *
27 * Gives the name "/" to the sysfs_root entry; any path returned 27 * Gives the name "/" to the sysfs_root entry; any path returned
28 * is relative to wherever sysfs is mounted. 28 * is relative to wherever sysfs is mounted.
29 */ 29 */
30static char *sysfs_pathname(struct sysfs_dirent *sd, char *path) 30static char *sysfs_pathname(struct kernfs_node *kn, char *path)
31{ 31{
32 if (sd->s_parent) { 32 if (kn->s_parent) {
33 sysfs_pathname(sd->s_parent, path); 33 sysfs_pathname(kn->s_parent, path);
34 strlcat(path, "/", PATH_MAX); 34 strlcat(path, "/", PATH_MAX);
35 } 35 }
36 strlcat(path, sd->s_name, PATH_MAX); 36 strlcat(path, kn->s_name, PATH_MAX);
37 return path; 37 return path;
38} 38}
39 39
40void sysfs_warn_dup(struct sysfs_dirent *parent, const char *name) 40void sysfs_warn_dup(struct kernfs_node *parent, const char *name)
41{ 41{
42 char *path; 42 char *path;
43 43
@@ -61,26 +61,26 @@ void sysfs_warn_dup(struct sysfs_dirent *parent, const char *name)
61 */ 61 */
62int sysfs_create_dir_ns(struct kobject *kobj, const void *ns) 62int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
63{ 63{
64 struct sysfs_dirent *parent_sd, *sd; 64 struct kernfs_node *parent, *kn;
65 65
66 BUG_ON(!kobj); 66 BUG_ON(!kobj);
67 67
68 if (kobj->parent) 68 if (kobj->parent)
69 parent_sd = kobj->parent->sd; 69 parent = kobj->parent->sd;
70 else 70 else
71 parent_sd = sysfs_root_sd; 71 parent = sysfs_root_kn;
72 72
73 if (!parent_sd) 73 if (!parent)
74 return -ENOENT; 74 return -ENOENT;
75 75
76 sd = kernfs_create_dir_ns(parent_sd, kobject_name(kobj), kobj, ns); 76 kn = kernfs_create_dir_ns(parent, kobject_name(kobj), kobj, ns);
77 if (IS_ERR(sd)) { 77 if (IS_ERR(kn)) {
78 if (PTR_ERR(sd) == -EEXIST) 78 if (PTR_ERR(kn) == -EEXIST)
79 sysfs_warn_dup(parent_sd, kobject_name(kobj)); 79 sysfs_warn_dup(parent, kobject_name(kobj));
80 return PTR_ERR(sd); 80 return PTR_ERR(kn);
81 } 81 }
82 82
83 kobj->sd = sd; 83 kobj->sd = kn;
84 return 0; 84 return 0;
85} 85}
86 86
@@ -94,47 +94,47 @@ int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
94 */ 94 */
95void sysfs_remove_dir(struct kobject *kobj) 95void sysfs_remove_dir(struct kobject *kobj)
96{ 96{
97 struct sysfs_dirent *sd = kobj->sd; 97 struct kernfs_node *kn = kobj->sd;
98 98
99 /* 99 /*
100 * In general, kboject owner is responsible for ensuring removal 100 * In general, kboject owner is responsible for ensuring removal
101 * doesn't race with other operations and sysfs doesn't provide any 101 * doesn't race with other operations and sysfs doesn't provide any
102 * protection; however, when @kobj is used as a symlink target, the 102 * protection; however, when @kobj is used as a symlink target, the
103 * symlinking entity usually doesn't own @kobj and thus has no 103 * symlinking entity usually doesn't own @kobj and thus has no
104 * control over removal. @kobj->sd may be removed anytime and 104 * control over removal. @kobj->sd may be removed anytime
105 * symlink code may end up dereferencing an already freed sd. 105 * and symlink code may end up dereferencing an already freed node.
106 * 106 *
107 * sysfs_symlink_target_lock synchronizes @kobj->sd disassociation 107 * sysfs_symlink_target_lock synchronizes @kobj->sd
108 * against symlink operations so that symlink code can safely 108 * disassociation against symlink operations so that symlink code
109 * dereference @kobj->sd. 109 * can safely dereference @kobj->sd.
110 */ 110 */
111 spin_lock(&sysfs_symlink_target_lock); 111 spin_lock(&sysfs_symlink_target_lock);
112 kobj->sd = NULL; 112 kobj->sd = NULL;
113 spin_unlock(&sysfs_symlink_target_lock); 113 spin_unlock(&sysfs_symlink_target_lock);
114 114
115 if (sd) { 115 if (kn) {
116 WARN_ON_ONCE(sysfs_type(sd) != SYSFS_DIR); 116 WARN_ON_ONCE(sysfs_type(kn) != SYSFS_DIR);
117 kernfs_remove(sd); 117 kernfs_remove(kn);
118 } 118 }
119} 119}
120 120
121int sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name, 121int sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name,
122 const void *new_ns) 122 const void *new_ns)
123{ 123{
124 struct sysfs_dirent *parent_sd = kobj->sd->s_parent; 124 struct kernfs_node *parent = kobj->sd->s_parent;
125 125
126 return kernfs_rename_ns(kobj->sd, parent_sd, new_name, new_ns); 126 return kernfs_rename_ns(kobj->sd, parent, new_name, new_ns);
127} 127}
128 128
129int sysfs_move_dir_ns(struct kobject *kobj, struct kobject *new_parent_kobj, 129int sysfs_move_dir_ns(struct kobject *kobj, struct kobject *new_parent_kobj,
130 const void *new_ns) 130 const void *new_ns)
131{ 131{
132 struct sysfs_dirent *sd = kobj->sd; 132 struct kernfs_node *kn = kobj->sd;
133 struct sysfs_dirent *new_parent_sd; 133 struct kernfs_node *new_parent;
134 134
135 BUG_ON(!sd->s_parent); 135 BUG_ON(!kn->s_parent);
136 new_parent_sd = new_parent_kobj && new_parent_kobj->sd ? 136 new_parent = new_parent_kobj && new_parent_kobj->sd ?
137 new_parent_kobj->sd : sysfs_root_sd; 137 new_parent_kobj->sd : sysfs_root_kn;
138 138
139 return kernfs_rename_ns(sd, new_parent_sd, sd->s_name, new_ns); 139 return kernfs_rename_ns(kn, new_parent, kn->s_name, new_ns);
140} 140}