aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernfs.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-11-28 14:54:30 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-11-29 20:55:10 -0500
commitccf73cf336dc55bc52748205dee998d2fd4a8808 (patch)
tree8e3a3b9891e6b9d4804299cd23110c91d8f8016e /include/linux/kernfs.h
parent517e64f57883bd63c5a4ab8b3d0d3ed68c55d0cf (diff)
sysfs, kernfs: introduce kernfs[_find_and]_get() and kernfs_put()
Introduce kernfs interface for finding, getting and putting sysfs_dirents. * sysfs_find_dirent() is renamed to kernfs_find_ns() and lockdep assertion for sysfs_mutex is added. * sysfs_get_dirent_ns() is renamed to kernfs_find_and_get(). * Macro inline dancing around __sysfs_get/put() are removed and kernfs_get/put() are made proper functions implemented in fs/sysfs/dir.c. While the conversions are mostly equivalent, there's one difference - kernfs_get() doesn't return the input param as its return value. This change is intentional. While passing through the input increases writability in some areas, it is unnecessary and has been shown to cause confusion regarding how the last ref is handled. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/kernfs.h')
-rw-r--r--include/linux/kernfs.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
index 105d09dcb064..fd8f574ef2fe 100644
--- a/include/linux/kernfs.h
+++ b/include/linux/kernfs.h
@@ -71,6 +71,11 @@ struct kernfs_ops {
71 71
72#ifdef CONFIG_SYSFS 72#ifdef CONFIG_SYSFS
73 73
74struct sysfs_dirent *kernfs_find_and_get_ns(struct sysfs_dirent *parent,
75 const char *name, const void *ns);
76void kernfs_get(struct sysfs_dirent *sd);
77void kernfs_put(struct sysfs_dirent *sd);
78
74struct sysfs_dirent *kernfs_create_dir_ns(struct sysfs_dirent *parent, 79struct sysfs_dirent *kernfs_create_dir_ns(struct sysfs_dirent *parent,
75 const char *name, void *priv, 80 const char *name, void *priv,
76 const void *ns); 81 const void *ns);
@@ -95,6 +100,14 @@ void kernfs_notify(struct sysfs_dirent *sd);
95#else /* CONFIG_SYSFS */ 100#else /* CONFIG_SYSFS */
96 101
97static inline struct sysfs_dirent * 102static inline struct sysfs_dirent *
103kernfs_find_and_get_ns(struct sysfs_dirent *parent, const char *name,
104 const void *ns)
105{ return NULL; }
106
107static inline void kernfs_get(struct sysfs_dirent *sd) { }
108static inline void kernfs_put(struct sysfs_dirent *sd) { }
109
110static inline struct sysfs_dirent *
98kernfs_create_dir_ns(struct sysfs_dirent *parent, const char *name, void *priv, 111kernfs_create_dir_ns(struct sysfs_dirent *parent, const char *name, void *priv,
99 const void *ns) 112 const void *ns)
100{ return ERR_PTR(-ENOSYS); } 113{ return ERR_PTR(-ENOSYS); }
@@ -133,6 +146,12 @@ static inline void kernfs_notify(struct sysfs_dirent *sd) { }
133#endif /* CONFIG_SYSFS */ 146#endif /* CONFIG_SYSFS */
134 147
135static inline struct sysfs_dirent * 148static inline struct sysfs_dirent *
149kernfs_find_and_get(struct sysfs_dirent *sd, const char *name)
150{
151 return kernfs_find_and_get_ns(sd, name, NULL);
152}
153
154static inline struct sysfs_dirent *
136kernfs_create_dir(struct sysfs_dirent *parent, const char *name, void *priv) 155kernfs_create_dir(struct sysfs_dirent *parent, const char *name, void *priv)
137{ 156{
138 return kernfs_create_dir_ns(parent, name, priv, NULL); 157 return kernfs_create_dir_ns(parent, name, priv, NULL);