summaryrefslogtreecommitdiffstats
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,
struct bin_attribute *battr = of->sd->priv;
struct kobject *kobj = of->sd->s_parent->priv;
- if (!battr->mmap)
- return -ENODEV;
-
return battr->mmap(of->file, kobj, battr, vma);
}
@@ -197,6 +194,11 @@ static const struct kernfs_ops sysfs_bin_kfops_wo = {
static const struct kernfs_ops sysfs_bin_kfops_rw = {
.read = sysfs_kf_bin_read,
.write = sysfs_kf_bin_write,
+};
+
+static const struct kernfs_ops sysfs_bin_kfops_mmap = {
+ .read = sysfs_kf_bin_read,
+ .write = sysfs_kf_bin_write,
.mmap = sysfs_kf_bin_mmap,
};
@@ -232,7 +234,9 @@ int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd,
} else {
struct bin_attribute *battr = (void *)attr;
- if ((battr->read && battr->write) || battr->mmap)
+ if (battr->mmap)
+ ops = &sysfs_bin_kfops_mmap;
+ else if (battr->read && battr->write)
ops = &sysfs_bin_kfops_rw;
else if (battr->read)
ops = &sysfs_bin_kfops_ro;
OpenPOWER on IntegriCloud