aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Brandenburg <martin@omnibond.com>2016-08-15 15:01:30 -0400
committerMartin Brandenburg <martin@omnibond.com>2016-08-15 15:01:30 -0400
commit4a3436647ac5161a8a8e797f89c2f8f52b947d59 (patch)
tree52ccfed90e7beac58110a71bacadd876787df311
parent7b0cae60ffa216cff3ba6bd5ac2c7be0ca2c1467 (diff)
orangefs: remove duplicated sysfs_ops structures
Signed-off-by: Martin Brandenburg <martin@omnibond.com>
-rw-r--r--fs/orangefs/orangefs-sysfs.c73
1 files changed, 15 insertions, 58 deletions
diff --git a/fs/orangefs/orangefs-sysfs.c b/fs/orangefs/orangefs-sysfs.c
index 2642cb2f26b2..a772d26ad9d9 100644
--- a/fs/orangefs/orangefs-sysfs.c
+++ b/fs/orangefs/orangefs-sysfs.c
@@ -155,19 +155,11 @@ static ssize_t orangefs_attr_show(struct kobject *kobj,
155 char *buf) 155 char *buf)
156{ 156{
157 struct orangefs_attribute *attribute; 157 struct orangefs_attribute *attribute;
158 int rc;
159 158
160 attribute = container_of(attr, struct orangefs_attribute, attr); 159 attribute = container_of(attr, struct orangefs_attribute, attr);
161 160 if (!attribute->show)
162 if (!attribute->show) { 161 return -EIO;
163 rc = -EIO; 162 return attribute->show(kobj, attribute, buf);
164 goto out;
165 }
166
167 rc = attribute->show(kobj, attribute, buf);
168
169out:
170 return rc;
171} 163}
172 164
173static ssize_t orangefs_attr_store(struct kobject *kobj, 165static ssize_t orangefs_attr_store(struct kobject *kobj,
@@ -176,22 +168,15 @@ static ssize_t orangefs_attr_store(struct kobject *kobj,
176 size_t len) 168 size_t len)
177{ 169{
178 struct orangefs_attribute *attribute; 170 struct orangefs_attribute *attribute;
179 int rc;
180 171
181 gossip_debug(GOSSIP_SYSFS_DEBUG, 172 if (!strcmp(kobj->name, PC_KOBJ_ID) ||
182 "orangefs_attr_store: start\n"); 173 !strcmp(kobj->name, STATS_KOBJ_ID))
174 return -EPERM;
183 175
184 attribute = container_of(attr, struct orangefs_attribute, attr); 176 attribute = container_of(attr, struct orangefs_attribute, attr);
185 177 if (!attribute->store)
186 if (!attribute->store) { 178 return -EIO;
187 rc = -EIO; 179 return attribute->store(kobj, attribute, buf, len);
188 goto out;
189 }
190
191 rc = attribute->store(kobj, attribute, buf, len);
192
193out:
194 return rc;
195} 180}
196 181
197static const struct sysfs_ops orangefs_sysfs_ops = { 182static const struct sysfs_ops orangefs_sysfs_ops = {
@@ -199,34 +184,6 @@ static const struct sysfs_ops orangefs_sysfs_ops = {
199 .store = orangefs_attr_store, 184 .store = orangefs_attr_store,
200}; 185};
201 186
202static const struct sysfs_ops acache_orangefs_sysfs_ops = {
203 .show = orangefs_attr_show,
204 .store = orangefs_attr_store,
205};
206
207static const struct sysfs_ops capcache_orangefs_sysfs_ops = {
208 .show = orangefs_attr_show,
209 .store = orangefs_attr_store,
210};
211
212static const struct sysfs_ops ccache_orangefs_sysfs_ops = {
213 .show = orangefs_attr_show,
214 .store = orangefs_attr_store,
215};
216
217static const struct sysfs_ops ncache_orangefs_sysfs_ops = {
218 .show = orangefs_attr_show,
219 .store = orangefs_attr_store,
220};
221
222static const struct sysfs_ops pc_orangefs_sysfs_ops = {
223 .show = orangefs_attr_show,
224};
225
226static const struct sysfs_ops stats_orangefs_sysfs_ops = {
227 .show = orangefs_attr_show,
228};
229
230static ssize_t sysfs_int_show(struct kobject *kobj, 187static ssize_t sysfs_int_show(struct kobject *kobj,
231 struct orangefs_attribute *attr, char *buf) 188 struct orangefs_attribute *attr, char *buf)
232{ 189{
@@ -909,7 +866,7 @@ static struct attribute *acache_orangefs_default_attrs[] = {
909}; 866};
910 867
911static struct kobj_type acache_orangefs_ktype = { 868static struct kobj_type acache_orangefs_ktype = {
912 .sysfs_ops = &acache_orangefs_sysfs_ops, 869 .sysfs_ops = &orangefs_sysfs_ops,
913 .default_attrs = acache_orangefs_default_attrs, 870 .default_attrs = acache_orangefs_default_attrs,
914}; 871};
915 872
@@ -946,7 +903,7 @@ static struct attribute *capcache_orangefs_default_attrs[] = {
946}; 903};
947 904
948static struct kobj_type capcache_orangefs_ktype = { 905static struct kobj_type capcache_orangefs_ktype = {
949 .sysfs_ops = &capcache_orangefs_sysfs_ops, 906 .sysfs_ops = &orangefs_sysfs_ops,
950 .default_attrs = capcache_orangefs_default_attrs, 907 .default_attrs = capcache_orangefs_default_attrs,
951}; 908};
952 909
@@ -983,7 +940,7 @@ static struct attribute *ccache_orangefs_default_attrs[] = {
983}; 940};
984 941
985static struct kobj_type ccache_orangefs_ktype = { 942static struct kobj_type ccache_orangefs_ktype = {
986 .sysfs_ops = &ccache_orangefs_sysfs_ops, 943 .sysfs_ops = &orangefs_sysfs_ops,
987 .default_attrs = ccache_orangefs_default_attrs, 944 .default_attrs = ccache_orangefs_default_attrs,
988}; 945};
989 946
@@ -1020,7 +977,7 @@ static struct attribute *ncache_orangefs_default_attrs[] = {
1020}; 977};
1021 978
1022static struct kobj_type ncache_orangefs_ktype = { 979static struct kobj_type ncache_orangefs_ktype = {
1023 .sysfs_ops = &ncache_orangefs_sysfs_ops, 980 .sysfs_ops = &orangefs_sysfs_ops,
1024 .default_attrs = ncache_orangefs_default_attrs, 981 .default_attrs = ncache_orangefs_default_attrs,
1025}; 982};
1026 983
@@ -1050,7 +1007,7 @@ static struct attribute *pc_orangefs_default_attrs[] = {
1050}; 1007};
1051 1008
1052static struct kobj_type pc_orangefs_ktype = { 1009static struct kobj_type pc_orangefs_ktype = {
1053 .sysfs_ops = &pc_orangefs_sysfs_ops, 1010 .sysfs_ops = &orangefs_sysfs_ops,
1054 .default_attrs = pc_orangefs_default_attrs, 1011 .default_attrs = pc_orangefs_default_attrs,
1055}; 1012};
1056 1013
@@ -1073,7 +1030,7 @@ static struct attribute *stats_orangefs_default_attrs[] = {
1073}; 1030};
1074 1031
1075static struct kobj_type stats_orangefs_ktype = { 1032static struct kobj_type stats_orangefs_ktype = {
1076 .sysfs_ops = &stats_orangefs_sysfs_ops, 1033 .sysfs_ops = &orangefs_sysfs_ops,
1077 .default_attrs = stats_orangefs_default_attrs, 1034 .default_attrs = stats_orangefs_default_attrs,
1078}; 1035};
1079 1036