Commit a7dc66dfb4c6d6c1d7c14d5106ce467f1dbd4eba
Committed by
Greg Kroah-Hartman
1 parent
471bd7b78b
Exists in
master
and in
16 other branches
sysfs, kernfs: remove SYSFS_KOBJ_BIN_ATTR
After kernfs_ops and sysfs_dirent->s_attr.size addition, the distinction between SYSFS_KOBJ_BIN_ATTR and SYSFS_KOBJ_ATTR is only necessary while creating files to decide which kernfs_ops to use. Afterwards, they behave exactly the same. This patch removes SYSFS_KOBJ_BIN_ATTR along with sysfs_is_bin(). sysfs_add_file[_mode_ns]() are updated to take bool @is_bin instead of @type. This patch doesn't introduce any behavior changes. This completely isolates the distinction between the two sysfs file types in the sysfs layer proper. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing 4 changed files with 14 additions and 26 deletions Side-by-side Diff
fs/sysfs/file.c
... | ... | @@ -47,11 +47,6 @@ |
47 | 47 | struct list_head files; /* goes through sysfs_open_file.list */ |
48 | 48 | }; |
49 | 49 | |
50 | -static bool sysfs_is_bin(struct sysfs_dirent *sd) | |
51 | -{ | |
52 | - return sysfs_type(sd) == SYSFS_KOBJ_BIN_ATTR; | |
53 | -} | |
54 | - | |
55 | 50 | static struct sysfs_open_file *sysfs_of(struct file *file) |
56 | 51 | { |
57 | 52 | return ((struct seq_file *)file->private_data)->private; |
... | ... | @@ -916,7 +911,7 @@ |
916 | 911 | }; |
917 | 912 | |
918 | 913 | int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd, |
919 | - const struct attribute *attr, int type, | |
914 | + const struct attribute *attr, bool is_bin, | |
920 | 915 | umode_t amode, const void *ns) |
921 | 916 | { |
922 | 917 | umode_t mode = (amode & S_IALLUGO) | S_IFREG; |
... | ... | @@ -926,7 +921,7 @@ |
926 | 921 | loff_t size; |
927 | 922 | int rc; |
928 | 923 | |
929 | - if (type == SYSFS_KOBJ_ATTR) { | |
924 | + if (!is_bin) { | |
930 | 925 | struct kobject *kobj = dir_sd->priv; |
931 | 926 | const struct sysfs_ops *sysfs_ops = kobj->ktype->sysfs_ops; |
932 | 927 | |
... | ... | @@ -961,7 +956,7 @@ |
961 | 956 | size = battr->size; |
962 | 957 | } |
963 | 958 | |
964 | - sd = sysfs_new_dirent(attr->name, mode, type); | |
959 | + sd = sysfs_new_dirent(attr->name, mode, SYSFS_KOBJ_ATTR); | |
965 | 960 | if (!sd) |
966 | 961 | return -ENOMEM; |
967 | 962 | |
968 | 963 | |
969 | 964 | |
... | ... | @@ -991,11 +986,10 @@ |
991 | 986 | return rc; |
992 | 987 | } |
993 | 988 | |
994 | - | |
995 | 989 | int sysfs_add_file(struct sysfs_dirent *dir_sd, const struct attribute *attr, |
996 | - int type) | |
990 | + bool is_bin) | |
997 | 991 | { |
998 | - return sysfs_add_file_mode_ns(dir_sd, attr, type, attr->mode, NULL); | |
992 | + return sysfs_add_file_mode_ns(dir_sd, attr, is_bin, attr->mode, NULL); | |
999 | 993 | } |
1000 | 994 | |
1001 | 995 | /** |
... | ... | @@ -1009,8 +1003,7 @@ |
1009 | 1003 | { |
1010 | 1004 | BUG_ON(!kobj || !kobj->sd || !attr); |
1011 | 1005 | |
1012 | - return sysfs_add_file_mode_ns(kobj->sd, attr, SYSFS_KOBJ_ATTR, | |
1013 | - attr->mode, ns); | |
1006 | + return sysfs_add_file_mode_ns(kobj->sd, attr, false, attr->mode, ns); | |
1014 | 1007 | |
1015 | 1008 | } |
1016 | 1009 | EXPORT_SYMBOL_GPL(sysfs_create_file_ns); |
... | ... | @@ -1049,7 +1042,7 @@ |
1049 | 1042 | if (!dir_sd) |
1050 | 1043 | return -ENOENT; |
1051 | 1044 | |
1052 | - error = sysfs_add_file(dir_sd, attr, SYSFS_KOBJ_ATTR); | |
1045 | + error = sysfs_add_file(dir_sd, attr, false); | |
1053 | 1046 | sysfs_put(dir_sd); |
1054 | 1047 | |
1055 | 1048 | return error; |
... | ... | @@ -1141,7 +1134,7 @@ |
1141 | 1134 | { |
1142 | 1135 | BUG_ON(!kobj || !kobj->sd || !attr); |
1143 | 1136 | |
1144 | - return sysfs_add_file(kobj->sd, &attr->attr, SYSFS_KOBJ_BIN_ATTR); | |
1137 | + return sysfs_add_file(kobj->sd, &attr->attr, true); | |
1145 | 1138 | } |
1146 | 1139 | EXPORT_SYMBOL_GPL(sysfs_create_bin_file); |
1147 | 1140 |
fs/sysfs/group.c
... | ... | @@ -55,8 +55,7 @@ |
55 | 55 | if (!mode) |
56 | 56 | continue; |
57 | 57 | } |
58 | - error = sysfs_add_file_mode_ns(dir_sd, *attr, | |
59 | - SYSFS_KOBJ_ATTR, | |
58 | + error = sysfs_add_file_mode_ns(dir_sd, *attr, false, | |
60 | 59 | (*attr)->mode | mode, |
61 | 60 | NULL); |
62 | 61 | if (unlikely(error)) |
... | ... | @@ -269,7 +268,7 @@ |
269 | 268 | return -ENOENT; |
270 | 269 | |
271 | 270 | for ((i = 0, attr = grp->attrs); *attr && !error; (++i, ++attr)) |
272 | - error = sysfs_add_file(dir_sd, *attr, SYSFS_KOBJ_ATTR); | |
271 | + error = sysfs_add_file(dir_sd, *attr, false); | |
273 | 272 | if (error) { |
274 | 273 | while (--i >= 0) |
275 | 274 | kernfs_remove_by_name(dir_sd, (*--attr)->name); |
fs/sysfs/inode.c
fs/sysfs/sysfs.h
... | ... | @@ -83,10 +83,9 @@ |
83 | 83 | #define SYSFS_TYPE_MASK 0x00ff |
84 | 84 | #define SYSFS_DIR 0x0001 |
85 | 85 | #define SYSFS_KOBJ_ATTR 0x0002 |
86 | -#define SYSFS_KOBJ_BIN_ATTR 0x0004 | |
87 | 86 | #define SYSFS_KOBJ_LINK 0x0008 |
88 | 87 | #define SYSFS_COPY_NAME (SYSFS_DIR | SYSFS_KOBJ_LINK) |
89 | -#define SYSFS_ACTIVE_REF (SYSFS_KOBJ_ATTR | SYSFS_KOBJ_BIN_ATTR) | |
88 | +#define SYSFS_ACTIVE_REF SYSFS_KOBJ_ATTR | |
90 | 89 | |
91 | 90 | #define SYSFS_FLAG_MASK ~SYSFS_TYPE_MASK |
92 | 91 | #define SYSFS_FLAG_NS 0x01000 |
93 | 92 | |
... | ... | @@ -115,10 +114,8 @@ |
115 | 114 | static inline bool sysfs_ignore_lockdep(struct sysfs_dirent *sd) |
116 | 115 | { |
117 | 116 | struct attribute *attr = sd->priv; |
118 | - int type = sysfs_type(sd); | |
119 | 117 | |
120 | - return (type == SYSFS_KOBJ_ATTR || type == SYSFS_KOBJ_BIN_ATTR) && | |
121 | - attr->ignore_lockdep; | |
118 | + return sysfs_type(sd) == SYSFS_KOBJ_ATTR && attr->ignore_lockdep; | |
122 | 119 | } |
123 | 120 | |
124 | 121 | #else |
125 | 122 | |
... | ... | @@ -219,10 +216,10 @@ |
219 | 216 | extern const struct file_operations kernfs_file_operations; |
220 | 217 | |
221 | 218 | int sysfs_add_file(struct sysfs_dirent *dir_sd, |
222 | - const struct attribute *attr, int type); | |
219 | + const struct attribute *attr, bool is_bin); | |
223 | 220 | |
224 | 221 | int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd, |
225 | - const struct attribute *attr, int type, | |
222 | + const struct attribute *attr, bool is_bin, | |
226 | 223 | umode_t amode, const void *ns); |
227 | 224 | void sysfs_unmap_bin_file(struct sysfs_dirent *sd); |
228 | 225 |