aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs/sysfs.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 /fs/sysfs/sysfs.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 'fs/sysfs/sysfs.h')
-rw-r--r--fs/sysfs/sysfs.h22
1 files changed, 0 insertions, 22 deletions
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index e93f8b845611..85315e228408 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -141,30 +141,8 @@ int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd,
141 struct sysfs_dirent *parent_sd); 141 struct sysfs_dirent *parent_sd);
142void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt); 142void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt);
143 143
144struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd,
145 const unsigned char *name,
146 const void *ns);
147struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type); 144struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type);
148 145
149void release_sysfs_dirent(struct sysfs_dirent *sd);
150
151static inline struct sysfs_dirent *__sysfs_get(struct sysfs_dirent *sd)
152{
153 if (sd) {
154 WARN_ON(!atomic_read(&sd->s_count));
155 atomic_inc(&sd->s_count);
156 }
157 return sd;
158}
159#define sysfs_get(sd) __sysfs_get(sd)
160
161static inline void __sysfs_put(struct sysfs_dirent *sd)
162{
163 if (sd && atomic_dec_and_test(&sd->s_count))
164 release_sysfs_dirent(sd);
165}
166#define sysfs_put(sd) __sysfs_put(sd)
167
168/* 146/*
169 * inode.c 147 * inode.c
170 */ 148 */