aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs/file.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/file.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/file.c')
-rw-r--r--fs/sysfs/file.c122
1 files changed, 61 insertions, 61 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index a67d1c682fed..be1cc39035bd 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -22,15 +22,15 @@
22#include "../kernfs/kernfs-internal.h" 22#include "../kernfs/kernfs-internal.h"
23 23
24/* 24/*
25 * Determine ktype->sysfs_ops for the given sysfs_dirent. This function 25 * Determine ktype->sysfs_ops for the given kernfs_node. This function
26 * must be called while holding an active reference. 26 * must be called while holding an active reference.
27 */ 27 */
28static const struct sysfs_ops *sysfs_file_ops(struct sysfs_dirent *sd) 28static const struct sysfs_ops *sysfs_file_ops(struct kernfs_node *kn)
29{ 29{
30 struct kobject *kobj = sd->s_parent->priv; 30 struct kobject *kobj = kn->s_parent->priv;
31 31
32 if (sd->s_flags & SYSFS_FLAG_LOCKDEP) 32 if (kn->s_flags & SYSFS_FLAG_LOCKDEP)
33 lockdep_assert_held(sd); 33 lockdep_assert_held(kn);
34 return kobj->ktype ? kobj->ktype->sysfs_ops : NULL; 34 return kobj->ktype ? kobj->ktype->sysfs_ops : NULL;
35} 35}
36 36
@@ -42,8 +42,8 @@ static const struct sysfs_ops *sysfs_file_ops(struct sysfs_dirent *sd)
42static int sysfs_kf_seq_show(struct seq_file *sf, void *v) 42static int sysfs_kf_seq_show(struct seq_file *sf, void *v)
43{ 43{
44 struct sysfs_open_file *of = sf->private; 44 struct sysfs_open_file *of = sf->private;
45 struct kobject *kobj = of->sd->s_parent->priv; 45 struct kobject *kobj = of->kn->s_parent->priv;
46 const struct sysfs_ops *ops = sysfs_file_ops(of->sd); 46 const struct sysfs_ops *ops = sysfs_file_ops(of->kn);
47 ssize_t count; 47 ssize_t count;
48 char *buf; 48 char *buf;
49 49
@@ -59,7 +59,7 @@ static int sysfs_kf_seq_show(struct seq_file *sf, void *v)
59 * if @ops->show() isn't implemented. 59 * if @ops->show() isn't implemented.
60 */ 60 */
61 if (ops->show) { 61 if (ops->show) {
62 count = ops->show(kobj, of->sd->priv, buf); 62 count = ops->show(kobj, of->kn->priv, buf);
63 if (count < 0) 63 if (count < 0)
64 return count; 64 return count;
65 } 65 }
@@ -81,8 +81,8 @@ static int sysfs_kf_seq_show(struct seq_file *sf, void *v)
81static ssize_t sysfs_kf_bin_read(struct sysfs_open_file *of, char *buf, 81static ssize_t sysfs_kf_bin_read(struct sysfs_open_file *of, char *buf,
82 size_t count, loff_t pos) 82 size_t count, loff_t pos)
83{ 83{
84 struct bin_attribute *battr = of->sd->priv; 84 struct bin_attribute *battr = of->kn->priv;
85 struct kobject *kobj = of->sd->s_parent->priv; 85 struct kobject *kobj = of->kn->s_parent->priv;
86 loff_t size = file_inode(of->file)->i_size; 86 loff_t size = file_inode(of->file)->i_size;
87 87
88 if (!count) 88 if (!count)
@@ -105,21 +105,21 @@ static ssize_t sysfs_kf_bin_read(struct sysfs_open_file *of, char *buf,
105static ssize_t sysfs_kf_write(struct sysfs_open_file *of, char *buf, 105static ssize_t sysfs_kf_write(struct sysfs_open_file *of, char *buf,
106 size_t count, loff_t pos) 106 size_t count, loff_t pos)
107{ 107{
108 const struct sysfs_ops *ops = sysfs_file_ops(of->sd); 108 const struct sysfs_ops *ops = sysfs_file_ops(of->kn);
109 struct kobject *kobj = of->sd->s_parent->priv; 109 struct kobject *kobj = of->kn->s_parent->priv;
110 110
111 if (!count) 111 if (!count)
112 return 0; 112 return 0;
113 113
114 return ops->store(kobj, of->sd->priv, buf, count); 114 return ops->store(kobj, of->kn->priv, buf, count);
115} 115}
116 116
117/* kernfs write callback for bin sysfs files */ 117/* kernfs write callback for bin sysfs files */
118static ssize_t sysfs_kf_bin_write(struct sysfs_open_file *of, char *buf, 118static ssize_t sysfs_kf_bin_write(struct sysfs_open_file *of, char *buf,
119 size_t count, loff_t pos) 119 size_t count, loff_t pos)
120{ 120{
121 struct bin_attribute *battr = of->sd->priv; 121 struct bin_attribute *battr = of->kn->priv;
122 struct kobject *kobj = of->sd->s_parent->priv; 122 struct kobject *kobj = of->kn->s_parent->priv;
123 loff_t size = file_inode(of->file)->i_size; 123 loff_t size = file_inode(of->file)->i_size;
124 124
125 if (size) { 125 if (size) {
@@ -139,30 +139,30 @@ static ssize_t sysfs_kf_bin_write(struct sysfs_open_file *of, char *buf,
139static int sysfs_kf_bin_mmap(struct sysfs_open_file *of, 139static int sysfs_kf_bin_mmap(struct sysfs_open_file *of,
140 struct vm_area_struct *vma) 140 struct vm_area_struct *vma)
141{ 141{
142 struct bin_attribute *battr = of->sd->priv; 142 struct bin_attribute *battr = of->kn->priv;
143 struct kobject *kobj = of->sd->s_parent->priv; 143 struct kobject *kobj = of->kn->s_parent->priv;
144 144
145 return battr->mmap(of->file, kobj, battr, vma); 145 return battr->mmap(of->file, kobj, battr, vma);
146} 146}
147 147
148void sysfs_notify(struct kobject *k, const char *dir, const char *attr) 148void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr)
149{ 149{
150 struct sysfs_dirent *sd = k->sd, *tmp; 150 struct kernfs_node *kn = kobj->sd, *tmp;
151 151
152 if (sd && dir) 152 if (kn && dir)
153 sd = kernfs_find_and_get(sd, dir); 153 kn = kernfs_find_and_get(kn, dir);
154 else 154 else
155 kernfs_get(sd); 155 kernfs_get(kn);
156 156
157 if (sd && attr) { 157 if (kn && attr) {
158 tmp = kernfs_find_and_get(sd, attr); 158 tmp = kernfs_find_and_get(kn, attr);
159 kernfs_put(sd); 159 kernfs_put(kn);
160 sd = tmp; 160 kn = tmp;
161 } 161 }
162 162
163 if (sd) { 163 if (kn) {
164 kernfs_notify(sd); 164 kernfs_notify(kn);
165 kernfs_put(sd); 165 kernfs_put(kn);
166 } 166 }
167} 167}
168EXPORT_SYMBOL_GPL(sysfs_notify); 168EXPORT_SYMBOL_GPL(sysfs_notify);
@@ -202,17 +202,17 @@ static const struct kernfs_ops sysfs_bin_kfops_mmap = {
202 .mmap = sysfs_kf_bin_mmap, 202 .mmap = sysfs_kf_bin_mmap,
203}; 203};
204 204
205int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd, 205int sysfs_add_file_mode_ns(struct kernfs_node *parent,
206 const struct attribute *attr, bool is_bin, 206 const struct attribute *attr, bool is_bin,
207 umode_t mode, const void *ns) 207 umode_t mode, const void *ns)
208{ 208{
209 struct lock_class_key *key = NULL; 209 struct lock_class_key *key = NULL;
210 const struct kernfs_ops *ops; 210 const struct kernfs_ops *ops;
211 struct sysfs_dirent *sd; 211 struct kernfs_node *kn;
212 loff_t size; 212 loff_t size;
213 213
214 if (!is_bin) { 214 if (!is_bin) {
215 struct kobject *kobj = dir_sd->priv; 215 struct kobject *kobj = parent->priv;
216 const struct sysfs_ops *sysfs_ops = kobj->ktype->sysfs_ops; 216 const struct sysfs_ops *sysfs_ops = kobj->ktype->sysfs_ops;
217 217
218 /* every kobject with an attribute needs a ktype assigned */ 218 /* every kobject with an attribute needs a ktype assigned */
@@ -252,20 +252,20 @@ int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd,
252 if (!attr->ignore_lockdep) 252 if (!attr->ignore_lockdep)
253 key = attr->key ?: (struct lock_class_key *)&attr->skey; 253 key = attr->key ?: (struct lock_class_key *)&attr->skey;
254#endif 254#endif
255 sd = kernfs_create_file_ns_key(dir_sd, attr->name, mode, size, 255 kn = kernfs_create_file_ns_key(parent, attr->name, mode, size,
256 ops, (void *)attr, ns, key); 256 ops, (void *)attr, ns, key);
257 if (IS_ERR(sd)) { 257 if (IS_ERR(kn)) {
258 if (PTR_ERR(sd) == -EEXIST) 258 if (PTR_ERR(kn) == -EEXIST)
259 sysfs_warn_dup(dir_sd, attr->name); 259 sysfs_warn_dup(parent, attr->name);
260 return PTR_ERR(sd); 260 return PTR_ERR(kn);
261 } 261 }
262 return 0; 262 return 0;
263} 263}
264 264
265int sysfs_add_file(struct sysfs_dirent *dir_sd, const struct attribute *attr, 265int sysfs_add_file(struct kernfs_node *parent, const struct attribute *attr,
266 bool is_bin) 266 bool is_bin)
267{ 267{
268 return sysfs_add_file_mode_ns(dir_sd, attr, is_bin, attr->mode, NULL); 268 return sysfs_add_file_mode_ns(parent, attr, is_bin, attr->mode, NULL);
269} 269}
270 270
271/** 271/**
@@ -307,21 +307,21 @@ EXPORT_SYMBOL_GPL(sysfs_create_files);
307int sysfs_add_file_to_group(struct kobject *kobj, 307int sysfs_add_file_to_group(struct kobject *kobj,
308 const struct attribute *attr, const char *group) 308 const struct attribute *attr, const char *group)
309{ 309{
310 struct sysfs_dirent *dir_sd; 310 struct kernfs_node *parent;
311 int error; 311 int error;
312 312
313 if (group) { 313 if (group) {
314 dir_sd = kernfs_find_and_get(kobj->sd, group); 314 parent = kernfs_find_and_get(kobj->sd, group);
315 } else { 315 } else {
316 dir_sd = kobj->sd; 316 parent = kobj->sd;
317 kernfs_get(dir_sd); 317 kernfs_get(parent);
318 } 318 }
319 319
320 if (!dir_sd) 320 if (!parent)
321 return -ENOENT; 321 return -ENOENT;
322 322
323 error = sysfs_add_file(dir_sd, attr, false); 323 error = sysfs_add_file(parent, attr, false);
324 kernfs_put(dir_sd); 324 kernfs_put(parent);
325 325
326 return error; 326 return error;
327} 327}
@@ -337,20 +337,20 @@ EXPORT_SYMBOL_GPL(sysfs_add_file_to_group);
337int sysfs_chmod_file(struct kobject *kobj, const struct attribute *attr, 337int sysfs_chmod_file(struct kobject *kobj, const struct attribute *attr,
338 umode_t mode) 338 umode_t mode)
339{ 339{
340 struct sysfs_dirent *sd; 340 struct kernfs_node *kn;
341 struct iattr newattrs; 341 struct iattr newattrs;
342 int rc; 342 int rc;
343 343
344 sd = kernfs_find_and_get(kobj->sd, attr->name); 344 kn = kernfs_find_and_get(kobj->sd, attr->name);
345 if (!sd) 345 if (!kn)
346 return -ENOENT; 346 return -ENOENT;
347 347
348 newattrs.ia_mode = (mode & S_IALLUGO) | (sd->s_mode & ~S_IALLUGO); 348 newattrs.ia_mode = (mode & S_IALLUGO) | (kn->s_mode & ~S_IALLUGO);
349 newattrs.ia_valid = ATTR_MODE; 349 newattrs.ia_valid = ATTR_MODE;
350 350
351 rc = kernfs_setattr(sd, &newattrs); 351 rc = kernfs_setattr(kn, &newattrs);
352 352
353 kernfs_put(sd); 353 kernfs_put(kn);
354 return rc; 354 return rc;
355} 355}
356EXPORT_SYMBOL_GPL(sysfs_chmod_file); 356EXPORT_SYMBOL_GPL(sysfs_chmod_file);
@@ -366,9 +366,9 @@ EXPORT_SYMBOL_GPL(sysfs_chmod_file);
366void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr, 366void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr,
367 const void *ns) 367 const void *ns)
368{ 368{
369 struct sysfs_dirent *dir_sd = kobj->sd; 369 struct kernfs_node *parent = kobj->sd;
370 370
371 kernfs_remove_by_name_ns(dir_sd, attr->name, ns); 371 kernfs_remove_by_name_ns(parent, attr->name, ns);
372} 372}
373EXPORT_SYMBOL_GPL(sysfs_remove_file_ns); 373EXPORT_SYMBOL_GPL(sysfs_remove_file_ns);
374 374
@@ -389,18 +389,18 @@ EXPORT_SYMBOL_GPL(sysfs_remove_files);
389void sysfs_remove_file_from_group(struct kobject *kobj, 389void sysfs_remove_file_from_group(struct kobject *kobj,
390 const struct attribute *attr, const char *group) 390 const struct attribute *attr, const char *group)
391{ 391{
392 struct sysfs_dirent *dir_sd; 392 struct kernfs_node *parent;
393 393
394 if (group) { 394 if (group) {
395 dir_sd = kernfs_find_and_get(kobj->sd, group); 395 parent = kernfs_find_and_get(kobj->sd, group);
396 } else { 396 } else {
397 dir_sd = kobj->sd; 397 parent = kobj->sd;
398 kernfs_get(dir_sd); 398 kernfs_get(parent);
399 } 399 }
400 400
401 if (dir_sd) { 401 if (parent) {
402 kernfs_remove_by_name(dir_sd, attr->name); 402 kernfs_remove_by_name(parent, attr->name);
403 kernfs_put(dir_sd); 403 kernfs_put(parent);
404 } 404 }
405} 405}
406EXPORT_SYMBOL_GPL(sysfs_remove_file_from_group); 406EXPORT_SYMBOL_GPL(sysfs_remove_file_from_group);