diff options
author | Tejun Heo <tj@kernel.org> | 2013-10-24 11:49:10 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-10-29 15:12:07 -0700 |
commit | 7eed6ecb0785681892ab1fe47188fc981241cfd0 (patch) | |
tree | 5f1c88f8bc17ae7beffcf0ed319ca9708bd3a082 /fs/sysfs/dir.c | |
parent | baa97cb50724e72ece05a7cead6533a9658ddf79 (diff) | |
download | op-kernel-dev-7eed6ecb0785681892ab1fe47188fc981241cfd0.zip op-kernel-dev-7eed6ecb0785681892ab1fe47188fc981241cfd0.tar.gz |
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/dir.c')
-rw-r--r-- | fs/sysfs/dir.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index eab59de..486238d 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, return pos->s_parent; } -void __sysfs_remove(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) +static void __sysfs_remove(struct sysfs_addrm_cxt *acxt, + struct sysfs_dirent *sd) { struct sysfs_dirent *pos, *next; @@ -847,6 +848,41 @@ void sysfs_remove(struct sysfs_dirent *sd) } /** + * sysfs_hash_and_remove - find a sysfs_dirent by name and remove it + * @dir_sd: parent of the target + * @name: name of the sysfs_dirent to remove + * @ns: namespace tag of the sysfs_dirent to remove + * + * Look for the sysfs_dirent with @name and @ns under @dir_sd and remove + * it. Returns 0 on success, -ENOENT if such entry doesn't exist. + */ +int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name, + const void *ns) +{ + struct sysfs_addrm_cxt acxt; + struct sysfs_dirent *sd; + + if (!dir_sd) { + WARN(1, KERN_WARNING "sysfs: can not remove '%s', no directory\n", + name); + return -ENOENT; + } + + sysfs_addrm_start(&acxt); + + sd = sysfs_find_dirent(dir_sd, name, ns); + if (sd) + __sysfs_remove(&acxt, sd); + + sysfs_addrm_finish(&acxt); + + if (sd) + return 0; + else + return -ENOENT; +} + +/** * sysfs_remove_dir - remove an object's directory. * @kobj: object. * |