aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-10-24 11:49:10 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-10-29 18:12:07 -0400
commit7eed6ecb0785681892ab1fe47188fc981241cfd0 (patch)
tree5f1c88f8bc17ae7beffcf0ed319ca9708bd3a082 /fs/sysfs
parentbaa97cb50724e72ece05a7cead6533a9658ddf79 (diff)
sysfs: move sysfs_hash_and_remove() to fs/sysfs/dir.c
Most removal related logic is implemented in fs/sysfs/dir.c. Move sysfs_hash_and_remove() to fs/sysfs/dir.c so that __sysfs_remove() doesn't have to be public. This is pure relocation. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/sysfs')
-rw-r--r--fs/sysfs/dir.c38
-rw-r--r--fs/sysfs/inode.c26
-rw-r--r--fs/sysfs/sysfs.h5
3 files changed, 39 insertions, 30 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index eab59de47556..486238d06021 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -813,7 +813,8 @@ static struct sysfs_dirent *sysfs_next_descendant_post(struct sysfs_dirent *pos,
813 return pos->s_parent; 813 return pos->s_parent;
814} 814}
815 815
816void __sysfs_remove(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) 816static void __sysfs_remove(struct sysfs_addrm_cxt *acxt,
817 struct sysfs_dirent *sd)
817{ 818{
818 struct sysfs_dirent *pos, *next; 819 struct sysfs_dirent *pos, *next;
819 820
@@ -847,6 +848,41 @@ void sysfs_remove(struct sysfs_dirent *sd)
847} 848}
848 849
849/** 850/**
851 * sysfs_hash_and_remove - find a sysfs_dirent by name and remove it
852 * @dir_sd: parent of the target
853 * @name: name of the sysfs_dirent to remove
854 * @ns: namespace tag of the sysfs_dirent to remove
855 *
856 * Look for the sysfs_dirent with @name and @ns under @dir_sd and remove
857 * it. Returns 0 on success, -ENOENT if such entry doesn't exist.
858 */
859int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name,
860 const void *ns)
861{
862 struct sysfs_addrm_cxt acxt;
863 struct sysfs_dirent *sd;
864
865 if (!dir_sd) {
866 WARN(1, KERN_WARNING "sysfs: can not remove '%s', no directory\n",
867 name);
868 return -ENOENT;
869 }
870
871 sysfs_addrm_start(&acxt);
872
873 sd = sysfs_find_dirent(dir_sd, name, ns);
874 if (sd)
875 __sysfs_remove(&acxt, sd);
876
877 sysfs_addrm_finish(&acxt);
878
879 if (sd)
880 return 0;
881 else
882 return -ENOENT;
883}
884
885/**
850 * sysfs_remove_dir - remove an object's directory. 886 * sysfs_remove_dir - remove an object's directory.
851 * @kobj: object. 887 * @kobj: object.
852 * 888 *
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 825c55607af8..1750f790af3b 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -314,32 +314,6 @@ void sysfs_evict_inode(struct inode *inode)
314 sysfs_put(sd); 314 sysfs_put(sd);
315} 315}
316 316
317int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name,
318 const void *ns)
319{
320 struct sysfs_addrm_cxt acxt;
321 struct sysfs_dirent *sd;
322
323 if (!dir_sd) {
324 WARN(1, KERN_WARNING "sysfs: can not remove '%s', no directory\n",
325 name);
326 return -ENOENT;
327 }
328
329 sysfs_addrm_start(&acxt);
330
331 sd = sysfs_find_dirent(dir_sd, name, ns);
332 if (sd)
333 __sysfs_remove(&acxt, sd);
334
335 sysfs_addrm_finish(&acxt);
336
337 if (sd)
338 return 0;
339 else
340 return -ENOENT;
341}
342
343int sysfs_permission(struct inode *inode, int mask) 317int sysfs_permission(struct inode *inode, int mask)
344{ 318{
345 struct sysfs_dirent *sd; 319 struct sysfs_dirent *sd;
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index e0753e5eff41..8d3dc1ddb546 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -172,8 +172,9 @@ int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd,
172 struct sysfs_dirent *parent_sd); 172 struct sysfs_dirent *parent_sd);
173int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd, 173int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd,
174 struct sysfs_dirent *parent_sd); 174 struct sysfs_dirent *parent_sd);
175void __sysfs_remove(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd);
176void sysfs_remove(struct sysfs_dirent *sd); 175void sysfs_remove(struct sysfs_dirent *sd);
176int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name,
177 const void *ns);
177void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt); 178void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt);
178 179
179struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd, 180struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd,
@@ -218,8 +219,6 @@ int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
218 struct kstat *stat); 219 struct kstat *stat);
219int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value, 220int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,
220 size_t size, int flags); 221 size_t size, int flags);
221int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name,
222 const void *ns);
223int sysfs_inode_init(void); 222int sysfs_inode_init(void);
224 223
225/* 224/*