aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernfs.h
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 /include/linux/kernfs.h
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 'include/linux/kernfs.h')
-rw-r--r--include/linux/kernfs.h166
1 files changed, 83 insertions, 83 deletions
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
index d65541308419..195d1c6a8b0c 100644
--- a/include/linux/kernfs.h
+++ b/include/linux/kernfs.h
@@ -46,61 +46,61 @@ enum kernfs_node_flag {
46 SYSFS_FLAG_LOCKDEP = 0x0100, 46 SYSFS_FLAG_LOCKDEP = 0x0100,
47}; 47};
48 48
49/* type-specific structures for sysfs_dirent->s_* union members */ 49/* type-specific structures for kernfs_node union members */
50struct sysfs_elem_dir { 50struct kernfs_elem_dir {
51 unsigned long subdirs; 51 unsigned long subdirs;
52 /* children rbtree starts here and goes through sd->s_rb */ 52 /* children rbtree starts here and goes through kn->s_rb */
53 struct rb_root children; 53 struct rb_root children;
54 54
55 /* 55 /*
56 * The kernfs hierarchy this directory belongs to. This fits 56 * The kernfs hierarchy this directory belongs to. This fits
57 * better directly in sysfs_dirent but is here to save space. 57 * better directly in kernfs_node but is here to save space.
58 */ 58 */
59 struct kernfs_root *root; 59 struct kernfs_root *root;
60}; 60};
61 61
62struct sysfs_elem_symlink { 62struct kernfs_elem_symlink {
63 struct sysfs_dirent *target_sd; 63 struct kernfs_node *target_kn;
64}; 64};
65 65
66struct sysfs_elem_attr { 66struct kernfs_elem_attr {
67 const struct kernfs_ops *ops; 67 const struct kernfs_ops *ops;
68 struct sysfs_open_dirent *open; 68 struct sysfs_open_dirent *open;
69 loff_t size; 69 loff_t size;
70}; 70};
71 71
72/* 72/*
73 * sysfs_dirent - the building block of sysfs hierarchy. Each and every 73 * kernfs_node - the building block of kernfs hierarchy. Each and every
74 * sysfs node is represented by single sysfs_dirent. Most fields are 74 * kernfs node is represented by single kernfs_node. Most fields are
75 * private to kernfs and shouldn't be accessed directly by kernfs users. 75 * private to kernfs and shouldn't be accessed directly by kernfs users.
76 * 76 *
77 * As long as s_count reference is held, the sysfs_dirent itself is 77 * As long as s_count reference is held, the kernfs_node itself is
78 * accessible. Dereferencing s_elem or any other outer entity 78 * accessible. Dereferencing elem or any other outer entity requires
79 * requires s_active reference. 79 * active reference.
80 */ 80 */
81struct sysfs_dirent { 81struct kernfs_node {
82 atomic_t s_count; 82 atomic_t s_count;
83 atomic_t s_active; 83 atomic_t s_active;
84#ifdef CONFIG_DEBUG_LOCK_ALLOC 84#ifdef CONFIG_DEBUG_LOCK_ALLOC
85 struct lockdep_map dep_map; 85 struct lockdep_map dep_map;
86#endif 86#endif
87 /* the following two fields are published */ 87 /* the following two fields are published */
88 struct sysfs_dirent *s_parent; 88 struct kernfs_node *s_parent;
89 const char *s_name; 89 const char *s_name;
90 90
91 struct rb_node s_rb; 91 struct rb_node s_rb;
92 92
93 union { 93 union {
94 struct completion *completion; 94 struct completion *completion;
95 struct sysfs_dirent *removed_list; 95 struct kernfs_node *removed_list;
96 } u; 96 } u;
97 97
98 const void *s_ns; /* namespace tag */ 98 const void *s_ns; /* namespace tag */
99 unsigned int s_hash; /* ns + name hash */ 99 unsigned int s_hash; /* ns + name hash */
100 union { 100 union {
101 struct sysfs_elem_dir s_dir; 101 struct kernfs_elem_dir s_dir;
102 struct sysfs_elem_symlink s_symlink; 102 struct kernfs_elem_symlink s_symlink;
103 struct sysfs_elem_attr s_attr; 103 struct kernfs_elem_attr s_attr;
104 }; 104 };
105 105
106 void *priv; 106 void *priv;
@@ -113,7 +113,7 @@ struct sysfs_dirent {
113 113
114struct kernfs_root { 114struct kernfs_root {
115 /* published fields */ 115 /* published fields */
116 struct sysfs_dirent *sd; 116 struct kernfs_node *kn;
117 117
118 /* private fields, do not use outside kernfs proper */ 118 /* private fields, do not use outside kernfs proper */
119 struct ida ino_ida; 119 struct ida ino_ida;
@@ -121,7 +121,7 @@ struct kernfs_root {
121 121
122struct sysfs_open_file { 122struct sysfs_open_file {
123 /* published fields */ 123 /* published fields */
124 struct sysfs_dirent *sd; 124 struct kernfs_node *kn;
125 struct file *file; 125 struct file *file;
126 126
127 /* private fields, do not use outside kernfs proper */ 127 /* private fields, do not use outside kernfs proper */
@@ -170,64 +170,64 @@ struct kernfs_ops {
170 170
171#ifdef CONFIG_SYSFS 171#ifdef CONFIG_SYSFS
172 172
173static inline enum kernfs_node_type sysfs_type(struct sysfs_dirent *sd) 173static inline enum kernfs_node_type sysfs_type(struct kernfs_node *kn)
174{ 174{
175 return sd->s_flags & SYSFS_TYPE_MASK; 175 return kn->s_flags & SYSFS_TYPE_MASK;
176} 176}
177 177
178/** 178/**
179 * kernfs_enable_ns - enable namespace under a directory 179 * kernfs_enable_ns - enable namespace under a directory
180 * @sd: directory of interest, should be empty 180 * @kn: directory of interest, should be empty
181 * 181 *
182 * This is to be called right after @sd is created to enable namespace 182 * This is to be called right after @kn is created to enable namespace
183 * under it. All children of @sd must have non-NULL namespace tags and 183 * under it. All children of @kn must have non-NULL namespace tags and
184 * only the ones which match the super_block's tag will be visible. 184 * only the ones which match the super_block's tag will be visible.
185 */ 185 */
186static inline void kernfs_enable_ns(struct sysfs_dirent *sd) 186static inline void kernfs_enable_ns(struct kernfs_node *kn)
187{ 187{
188 WARN_ON_ONCE(sysfs_type(sd) != SYSFS_DIR); 188 WARN_ON_ONCE(sysfs_type(kn) != SYSFS_DIR);
189 WARN_ON_ONCE(!RB_EMPTY_ROOT(&sd->s_dir.children)); 189 WARN_ON_ONCE(!RB_EMPTY_ROOT(&kn->s_dir.children));
190 sd->s_flags |= SYSFS_FLAG_NS; 190 kn->s_flags |= SYSFS_FLAG_NS;
191} 191}
192 192
193/** 193/**
194 * kernfs_ns_enabled - test whether namespace is enabled 194 * kernfs_ns_enabled - test whether namespace is enabled
195 * @sd: the node to test 195 * @kn: the node to test
196 * 196 *
197 * Test whether namespace filtering is enabled for the children of @ns. 197 * Test whether namespace filtering is enabled for the children of @ns.
198 */ 198 */
199static inline bool kernfs_ns_enabled(struct sysfs_dirent *sd) 199static inline bool kernfs_ns_enabled(struct kernfs_node *kn)
200{ 200{
201 return sd->s_flags & SYSFS_FLAG_NS; 201 return kn->s_flags & SYSFS_FLAG_NS;
202} 202}
203 203
204struct sysfs_dirent *kernfs_find_and_get_ns(struct sysfs_dirent *parent, 204struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent,
205 const char *name, const void *ns); 205 const char *name, const void *ns);
206void kernfs_get(struct sysfs_dirent *sd); 206void kernfs_get(struct kernfs_node *kn);
207void kernfs_put(struct sysfs_dirent *sd); 207void kernfs_put(struct kernfs_node *kn);
208 208
209struct kernfs_root *kernfs_create_root(void *priv); 209struct kernfs_root *kernfs_create_root(void *priv);
210void kernfs_destroy_root(struct kernfs_root *root); 210void kernfs_destroy_root(struct kernfs_root *root);
211 211
212struct sysfs_dirent *kernfs_create_dir_ns(struct sysfs_dirent *parent, 212struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent,
213 const char *name, void *priv, 213 const char *name, void *priv,
214 const void *ns); 214 const void *ns);
215struct sysfs_dirent *kernfs_create_file_ns_key(struct sysfs_dirent *parent, 215struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent,
216 const char *name, 216 const char *name,
217 umode_t mode, loff_t size, 217 umode_t mode, loff_t size,
218 const struct kernfs_ops *ops, 218 const struct kernfs_ops *ops,
219 void *priv, const void *ns, 219 void *priv, const void *ns,
220 struct lock_class_key *key); 220 struct lock_class_key *key);
221struct sysfs_dirent *kernfs_create_link(struct sysfs_dirent *parent, 221struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,
222 const char *name, 222 const char *name,
223 struct sysfs_dirent *target); 223 struct kernfs_node *target);
224void kernfs_remove(struct sysfs_dirent *sd); 224void kernfs_remove(struct kernfs_node *kn);
225int kernfs_remove_by_name_ns(struct sysfs_dirent *parent, const char *name, 225int kernfs_remove_by_name_ns(struct kernfs_node *parent, const char *name,
226 const void *ns); 226 const void *ns);
227int kernfs_rename_ns(struct sysfs_dirent *sd, struct sysfs_dirent *new_parent, 227int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
228 const char *new_name, const void *new_ns); 228 const char *new_name, const void *new_ns);
229int kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr); 229int kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr);
230void kernfs_notify(struct sysfs_dirent *sd); 230void kernfs_notify(struct kernfs_node *kn);
231 231
232const void *kernfs_super_ns(struct super_block *sb); 232const void *kernfs_super_ns(struct super_block *sb);
233struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags, 233struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags,
@@ -238,60 +238,60 @@ void kernfs_init(void);
238 238
239#else /* CONFIG_SYSFS */ 239#else /* CONFIG_SYSFS */
240 240
241static inline enum kernfs_node_type sysfs_type(struct sysfs_dirent *sd) 241static inline enum kernfs_node_type sysfs_type(struct kernfs_node *kn)
242{ return 0; } /* whatever */ 242{ return 0; } /* whatever */
243 243
244static inline void kernfs_enable_ns(struct sysfs_dirent *sd) { } 244static inline void kernfs_enable_ns(struct kernfs_node *kn) { }
245 245
246static inline bool kernfs_ns_enabled(struct sysfs_dirent *sd) 246static inline bool kernfs_ns_enabled(struct kernfs_node *kn)
247{ return false; } 247{ return false; }
248 248
249static inline struct sysfs_dirent * 249static inline struct kernfs_node *
250kernfs_find_and_get_ns(struct sysfs_dirent *parent, const char *name, 250kernfs_find_and_get_ns(struct kernfs_node *parent, const char *name,
251 const void *ns) 251 const void *ns)
252{ return NULL; } 252{ return NULL; }
253 253
254static inline void kernfs_get(struct sysfs_dirent *sd) { } 254static inline void kernfs_get(struct kernfs_node *kn) { }
255static inline void kernfs_put(struct sysfs_dirent *sd) { } 255static inline void kernfs_put(struct kernfs_node *kn) { }
256 256
257static inline struct kernfs_root *kernfs_create_root(void *priv) 257static inline struct kernfs_root *kernfs_create_root(void *priv)
258{ return ERR_PTR(-ENOSYS); } 258{ return ERR_PTR(-ENOSYS); }
259 259
260static inline void kernfs_destroy_root(struct kernfs_root *root) { } 260static inline void kernfs_destroy_root(struct kernfs_root *root) { }
261 261
262static inline struct sysfs_dirent * 262static inline struct kernfs_node *
263kernfs_create_dir_ns(struct sysfs_dirent *parent, const char *name, void *priv, 263kernfs_create_dir_ns(struct kernfs_node *parent, const char *name, void *priv,
264 const void *ns) 264 const void *ns)
265{ return ERR_PTR(-ENOSYS); } 265{ return ERR_PTR(-ENOSYS); }
266 266
267static inline struct sysfs_dirent * 267static inline struct kernfs_node *
268kernfs_create_file_ns_key(struct sysfs_dirent *parent, const char *name, 268kernfs_create_file_ns_key(struct kernfs_node *parent, const char *name,
269 umode_t mode, loff_t size, 269 umode_t mode, loff_t size,
270 const struct kernfs_ops *ops, void *priv, 270 const struct kernfs_ops *ops, void *priv,
271 const void *ns, struct lock_class_key *key) 271 const void *ns, struct lock_class_key *key)
272{ return ERR_PTR(-ENOSYS); } 272{ return ERR_PTR(-ENOSYS); }
273 273
274static inline struct sysfs_dirent * 274static inline struct kernfs_node *
275kernfs_create_link(struct sysfs_dirent *parent, const char *name, 275kernfs_create_link(struct kernfs_node *parent, const char *name,
276 struct sysfs_dirent *target) 276 struct kernfs_node *target)
277{ return ERR_PTR(-ENOSYS); } 277{ return ERR_PTR(-ENOSYS); }
278 278
279static inline void kernfs_remove(struct sysfs_dirent *sd) { } 279static inline void kernfs_remove(struct kernfs_node *kn) { }
280 280
281static inline int kernfs_remove_by_name_ns(struct sysfs_dirent *parent, 281static inline int kernfs_remove_by_name_ns(struct kernfs_node *kn,
282 const char *name, const void *ns) 282 const char *name, const void *ns)
283{ return -ENOSYS; } 283{ return -ENOSYS; }
284 284
285static inline int kernfs_rename_ns(struct sysfs_dirent *sd, 285static inline int kernfs_rename_ns(struct kernfs_node *kn,
286 struct sysfs_dirent *new_parent, 286 struct kernfs_node *new_parent,
287 const char *new_name, const void *new_ns) 287 const char *new_name, const void *new_ns)
288{ return -ENOSYS; } 288{ return -ENOSYS; }
289 289
290static inline int kernfs_setattr(struct sysfs_dirent *sd, 290static inline int kernfs_setattr(struct kernfs_node *kn,
291 const struct iattr *iattr) 291 const struct iattr *iattr)
292{ return -ENOSYS; } 292{ return -ENOSYS; }
293 293
294static inline void kernfs_notify(struct sysfs_dirent *sd) { } 294static inline void kernfs_notify(struct kernfs_node *kn) { }
295 295
296static inline const void *kernfs_super_ns(struct super_block *sb) 296static inline const void *kernfs_super_ns(struct super_block *sb)
297{ return NULL; } 297{ return NULL; }
@@ -307,20 +307,20 @@ static inline void kernfs_init(void) { }
307 307
308#endif /* CONFIG_SYSFS */ 308#endif /* CONFIG_SYSFS */
309 309
310static inline struct sysfs_dirent * 310static inline struct kernfs_node *
311kernfs_find_and_get(struct sysfs_dirent *sd, const char *name) 311kernfs_find_and_get(struct kernfs_node *kn, const char *name)
312{ 312{
313 return kernfs_find_and_get_ns(sd, name, NULL); 313 return kernfs_find_and_get_ns(kn, name, NULL);
314} 314}
315 315
316static inline struct sysfs_dirent * 316static inline struct kernfs_node *
317kernfs_create_dir(struct sysfs_dirent *parent, const char *name, void *priv) 317kernfs_create_dir(struct kernfs_node *parent, const char *name, void *priv)
318{ 318{
319 return kernfs_create_dir_ns(parent, name, priv, NULL); 319 return kernfs_create_dir_ns(parent, name, priv, NULL);
320} 320}
321 321
322static inline struct sysfs_dirent * 322static inline struct kernfs_node *
323kernfs_create_file_ns(struct sysfs_dirent *parent, const char *name, 323kernfs_create_file_ns(struct kernfs_node *parent, const char *name,
324 umode_t mode, loff_t size, const struct kernfs_ops *ops, 324 umode_t mode, loff_t size, const struct kernfs_ops *ops,
325 void *priv, const void *ns) 325 void *priv, const void *ns)
326{ 326{
@@ -333,14 +333,14 @@ kernfs_create_file_ns(struct sysfs_dirent *parent, const char *name,
333 ns, key); 333 ns, key);
334} 334}
335 335
336static inline struct sysfs_dirent * 336static inline struct kernfs_node *
337kernfs_create_file(struct sysfs_dirent *parent, const char *name, umode_t mode, 337kernfs_create_file(struct kernfs_node *parent, const char *name, umode_t mode,
338 loff_t size, const struct kernfs_ops *ops, void *priv) 338 loff_t size, const struct kernfs_ops *ops, void *priv)
339{ 339{
340 return kernfs_create_file_ns(parent, name, mode, size, ops, priv, NULL); 340 return kernfs_create_file_ns(parent, name, mode, size, ops, priv, NULL);
341} 341}
342 342
343static inline int kernfs_remove_by_name(struct sysfs_dirent *parent, 343static inline int kernfs_remove_by_name(struct kernfs_node *parent,
344 const char *name) 344 const char *name)
345{ 345{
346 return kernfs_remove_by_name_ns(parent, name, NULL); 346 return kernfs_remove_by_name_ns(parent, name, NULL);