aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/sysfs')
-rw-r--r--fs/sysfs/file.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index ac77d2be3c31..a67d1c682fed 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -142,9 +142,6 @@ static int sysfs_kf_bin_mmap(struct sysfs_open_file *of,
142 struct bin_attribute *battr = of->sd->priv; 142 struct bin_attribute *battr = of->sd->priv;
143 struct kobject *kobj = of->sd->s_parent->priv; 143 struct kobject *kobj = of->sd->s_parent->priv;
144 144
145 if (!battr->mmap)
146 return -ENODEV;
147
148 return battr->mmap(of->file, kobj, battr, vma); 145 return battr->mmap(of->file, kobj, battr, vma);
149} 146}
150 147
@@ -197,6 +194,11 @@ static const struct kernfs_ops sysfs_bin_kfops_wo = {
197static const struct kernfs_ops sysfs_bin_kfops_rw = { 194static const struct kernfs_ops sysfs_bin_kfops_rw = {
198 .read = sysfs_kf_bin_read, 195 .read = sysfs_kf_bin_read,
199 .write = sysfs_kf_bin_write, 196 .write = sysfs_kf_bin_write,
197};
198
199static const struct kernfs_ops sysfs_bin_kfops_mmap = {
200 .read = sysfs_kf_bin_read,
201 .write = sysfs_kf_bin_write,
200 .mmap = sysfs_kf_bin_mmap, 202 .mmap = sysfs_kf_bin_mmap,
201}; 203};
202 204
@@ -232,7 +234,9 @@ int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd,
232 } else { 234 } else {
233 struct bin_attribute *battr = (void *)attr; 235 struct bin_attribute *battr = (void *)attr;
234 236
235 if ((battr->read && battr->write) || battr->mmap) 237 if (battr->mmap)
238 ops = &sysfs_bin_kfops_mmap;
239 else if (battr->read && battr->write)
236 ops = &sysfs_bin_kfops_rw; 240 ops = &sysfs_bin_kfops_rw;
237 else if (battr->read) 241 else if (battr->read)
238 ops = &sysfs_bin_kfops_ro; 242 ops = &sysfs_bin_kfops_ro;