aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-11-23 17:21:49 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-11-27 16:57:56 -0500
commit879f40d193bb3c6c13930e88e3e9d5d7baf84d19 (patch)
treeb09863db44998ae61f572f816e93100cb56250cc /fs/sysfs
parentb8441ed279bff09a0a5ddeacf8f4087d2fb424ca (diff)
sysfs, kernfs: introduce kernfs_remove[_by_name[_ns]]()
Introduce kernfs removal interfaces - kernfs_remove() and kernfs_remove_by_name[_ns](). These are just renames of sysfs_remove() and sysfs_hash_and_remove(). No functional changes. v2: Dummy kernfs_remove_by_name_ns() for !CONFIG_SYSFS updated to return -ENOSYS instead of 0. 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.c20
-rw-r--r--fs/sysfs/file.c6
-rw-r--r--fs/sysfs/group.c15
-rw-r--r--fs/sysfs/symlink.c4
-rw-r--r--fs/sysfs/sysfs.h3
5 files changed, 22 insertions, 26 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 98701c00b9b0..edbde4e6e5e0 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -829,8 +829,8 @@ static struct sysfs_dirent *sysfs_next_descendant_post(struct sysfs_dirent *pos,
829 return pos->s_parent; 829 return pos->s_parent;
830} 830}
831 831
832static void __sysfs_remove(struct sysfs_addrm_cxt *acxt, 832static void __kernfs_remove(struct sysfs_addrm_cxt *acxt,
833 struct sysfs_dirent *sd) 833 struct sysfs_dirent *sd)
834{ 834{
835 struct sysfs_dirent *pos, *next; 835 struct sysfs_dirent *pos, *next;
836 836
@@ -849,22 +849,22 @@ static void __sysfs_remove(struct sysfs_addrm_cxt *acxt,
849} 849}
850 850
851/** 851/**
852 * sysfs_remove - remove a sysfs_dirent recursively 852 * kernfs_remove - remove a sysfs_dirent recursively
853 * @sd: the sysfs_dirent to remove 853 * @sd: the sysfs_dirent to remove
854 * 854 *
855 * Remove @sd along with all its subdirectories and files. 855 * Remove @sd along with all its subdirectories and files.
856 */ 856 */
857void sysfs_remove(struct sysfs_dirent *sd) 857void kernfs_remove(struct sysfs_dirent *sd)
858{ 858{
859 struct sysfs_addrm_cxt acxt; 859 struct sysfs_addrm_cxt acxt;
860 860
861 sysfs_addrm_start(&acxt); 861 sysfs_addrm_start(&acxt);
862 __sysfs_remove(&acxt, sd); 862 __kernfs_remove(&acxt, sd);
863 sysfs_addrm_finish(&acxt); 863 sysfs_addrm_finish(&acxt);
864} 864}
865 865
866/** 866/**
867 * sysfs_hash_and_remove - find a sysfs_dirent by name and remove it 867 * kernfs_remove_by_name_ns - find a sysfs_dirent by name and remove it
868 * @dir_sd: parent of the target 868 * @dir_sd: parent of the target
869 * @name: name of the sysfs_dirent to remove 869 * @name: name of the sysfs_dirent to remove
870 * @ns: namespace tag of the sysfs_dirent to remove 870 * @ns: namespace tag of the sysfs_dirent to remove
@@ -872,8 +872,8 @@ void sysfs_remove(struct sysfs_dirent *sd)
872 * Look for the sysfs_dirent with @name and @ns under @dir_sd and remove 872 * Look for the sysfs_dirent with @name and @ns under @dir_sd and remove
873 * it. Returns 0 on success, -ENOENT if such entry doesn't exist. 873 * it. Returns 0 on success, -ENOENT if such entry doesn't exist.
874 */ 874 */
875int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name, 875int kernfs_remove_by_name_ns(struct sysfs_dirent *dir_sd, const char *name,
876 const void *ns) 876 const void *ns)
877{ 877{
878 struct sysfs_addrm_cxt acxt; 878 struct sysfs_addrm_cxt acxt;
879 struct sysfs_dirent *sd; 879 struct sysfs_dirent *sd;
@@ -888,7 +888,7 @@ int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name,
888 888
889 sd = sysfs_find_dirent(dir_sd, name, ns); 889 sd = sysfs_find_dirent(dir_sd, name, ns);
890 if (sd) 890 if (sd)
891 __sysfs_remove(&acxt, sd); 891 __kernfs_remove(&acxt, sd);
892 892
893 sysfs_addrm_finish(&acxt); 893 sysfs_addrm_finish(&acxt);
894 894
@@ -928,7 +928,7 @@ void sysfs_remove_dir(struct kobject *kobj)
928 928
929 if (sd) { 929 if (sd) {
930 WARN_ON_ONCE(sysfs_type(sd) != SYSFS_DIR); 930 WARN_ON_ONCE(sysfs_type(sd) != SYSFS_DIR);
931 sysfs_remove(sd); 931 kernfs_remove(sd);
932 } 932 }
933} 933}
934 934
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 79b5da2acbe1..5664410136ba 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -952,7 +952,7 @@ void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr,
952{ 952{
953 struct sysfs_dirent *dir_sd = kobj->sd; 953 struct sysfs_dirent *dir_sd = kobj->sd;
954 954
955 sysfs_hash_and_remove(dir_sd, attr->name, ns); 955 kernfs_remove_by_name_ns(dir_sd, attr->name, ns);
956} 956}
957EXPORT_SYMBOL_GPL(sysfs_remove_file_ns); 957EXPORT_SYMBOL_GPL(sysfs_remove_file_ns);
958 958
@@ -980,7 +980,7 @@ void sysfs_remove_file_from_group(struct kobject *kobj,
980 else 980 else
981 dir_sd = sysfs_get(kobj->sd); 981 dir_sd = sysfs_get(kobj->sd);
982 if (dir_sd) { 982 if (dir_sd) {
983 sysfs_hash_and_remove(dir_sd, attr->name, NULL); 983 kernfs_remove_by_name(dir_sd, attr->name);
984 sysfs_put(dir_sd); 984 sysfs_put(dir_sd);
985 } 985 }
986} 986}
@@ -1008,7 +1008,7 @@ EXPORT_SYMBOL_GPL(sysfs_create_bin_file);
1008void sysfs_remove_bin_file(struct kobject *kobj, 1008void sysfs_remove_bin_file(struct kobject *kobj,
1009 const struct bin_attribute *attr) 1009 const struct bin_attribute *attr)
1010{ 1010{
1011 sysfs_hash_and_remove(kobj->sd, attr->attr.name, NULL); 1011 kernfs_remove_by_name(kobj->sd, attr->attr.name);
1012} 1012}
1013EXPORT_SYMBOL_GPL(sysfs_remove_bin_file); 1013EXPORT_SYMBOL_GPL(sysfs_remove_bin_file);
1014 1014
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index 1898a10e38ce..4bd997340830 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -26,7 +26,7 @@ static void remove_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
26 26
27 if (grp->attrs) 27 if (grp->attrs)
28 for (attr = grp->attrs; *attr; attr++) 28 for (attr = grp->attrs; *attr; attr++)
29 sysfs_hash_and_remove(dir_sd, (*attr)->name, NULL); 29 kernfs_remove_by_name(dir_sd, (*attr)->name);
30 if (grp->bin_attrs) 30 if (grp->bin_attrs)
31 for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++) 31 for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++)
32 sysfs_remove_bin_file(kobj, *bin_attr); 32 sysfs_remove_bin_file(kobj, *bin_attr);
@@ -49,8 +49,7 @@ static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
49 * re-adding (if required) the file. 49 * re-adding (if required) the file.
50 */ 50 */
51 if (update) 51 if (update)
52 sysfs_hash_and_remove(dir_sd, (*attr)->name, 52 kernfs_remove_by_name(dir_sd, (*attr)->name);
53 NULL);
54 if (grp->is_visible) { 53 if (grp->is_visible) {
55 mode = grp->is_visible(kobj, *attr, i); 54 mode = grp->is_visible(kobj, *attr, i);
56 if (!mode) 55 if (!mode)
@@ -111,7 +110,7 @@ static int internal_create_group(struct kobject *kobj, int update,
111 error = create_files(sd, kobj, grp, update); 110 error = create_files(sd, kobj, grp, update);
112 if (error) { 111 if (error) {
113 if (grp->name) 112 if (grp->name)
114 sysfs_remove(sd); 113 kernfs_remove(sd);
115 } 114 }
116 sysfs_put(sd); 115 sysfs_put(sd);
117 return error; 116 return error;
@@ -219,7 +218,7 @@ void sysfs_remove_group(struct kobject *kobj,
219 218
220 remove_files(sd, kobj, grp); 219 remove_files(sd, kobj, grp);
221 if (grp->name) 220 if (grp->name)
222 sysfs_remove(sd); 221 kernfs_remove(sd);
223 222
224 sysfs_put(sd); 223 sysfs_put(sd);
225} 224}
@@ -270,7 +269,7 @@ int sysfs_merge_group(struct kobject *kobj,
270 error = sysfs_add_file(dir_sd, *attr, SYSFS_KOBJ_ATTR); 269 error = sysfs_add_file(dir_sd, *attr, SYSFS_KOBJ_ATTR);
271 if (error) { 270 if (error) {
272 while (--i >= 0) 271 while (--i >= 0)
273 sysfs_hash_and_remove(dir_sd, (*--attr)->name, NULL); 272 kernfs_remove_by_name(dir_sd, (*--attr)->name);
274 } 273 }
275 sysfs_put(dir_sd); 274 sysfs_put(dir_sd);
276 275
@@ -292,7 +291,7 @@ void sysfs_unmerge_group(struct kobject *kobj,
292 dir_sd = sysfs_get_dirent(kobj->sd, grp->name); 291 dir_sd = sysfs_get_dirent(kobj->sd, grp->name);
293 if (dir_sd) { 292 if (dir_sd) {
294 for (attr = grp->attrs; *attr; ++attr) 293 for (attr = grp->attrs; *attr; ++attr)
295 sysfs_hash_and_remove(dir_sd, (*attr)->name, NULL); 294 kernfs_remove_by_name(dir_sd, (*attr)->name);
296 sysfs_put(dir_sd); 295 sysfs_put(dir_sd);
297 } 296 }
298} 297}
@@ -335,7 +334,7 @@ void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name,
335 334
336 dir_sd = sysfs_get_dirent(kobj->sd, group_name); 335 dir_sd = sysfs_get_dirent(kobj->sd, group_name);
337 if (dir_sd) { 336 if (dir_sd) {
338 sysfs_hash_and_remove(dir_sd, link_name, NULL); 337 kernfs_remove_by_name(dir_sd, link_name);
339 sysfs_put(dir_sd); 338 sysfs_put(dir_sd);
340 } 339 }
341} 340}
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index c660363fdaea..71583fc8100a 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -153,7 +153,7 @@ void sysfs_delete_link(struct kobject *kobj, struct kobject *targ,
153 if (targ->sd && (kobj->sd->s_flags & SYSFS_FLAG_NS)) 153 if (targ->sd && (kobj->sd->s_flags & SYSFS_FLAG_NS))
154 ns = targ->sd->s_ns; 154 ns = targ->sd->s_ns;
155 spin_unlock(&sysfs_symlink_target_lock); 155 spin_unlock(&sysfs_symlink_target_lock);
156 sysfs_hash_and_remove(kobj->sd, name, ns); 156 kernfs_remove_by_name_ns(kobj->sd, name, ns);
157} 157}
158 158
159/** 159/**
@@ -170,7 +170,7 @@ void sysfs_remove_link(struct kobject *kobj, const char *name)
170 else 170 else
171 parent_sd = kobj->sd; 171 parent_sd = kobj->sd;
172 172
173 sysfs_hash_and_remove(parent_sd, name, NULL); 173 kernfs_remove_by_name(parent_sd, name);
174} 174}
175EXPORT_SYMBOL_GPL(sysfs_remove_link); 175EXPORT_SYMBOL_GPL(sysfs_remove_link);
176 176
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index e116c21a27bf..97625b15ca03 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -173,9 +173,6 @@ int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd,
173 struct sysfs_dirent *parent_sd); 173 struct sysfs_dirent *parent_sd);
174int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd, 174int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd,
175 struct sysfs_dirent *parent_sd); 175 struct sysfs_dirent *parent_sd);
176void sysfs_remove(struct sysfs_dirent *sd);
177int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name,
178 const void *ns);
179void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt); 176void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt);
180 177
181struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd, 178struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd,