--- linux-3.14/fs/kernfs/file.c.orig 2014-03-31 05:40:15.000000000 +0200 +++ linux-3.14/fs/kernfs/file.c 2014-04-19 08:22:11.754042780 +0200 @@ -458,16 +458,6 @@ const struct kernfs_ops *ops; int rc; - /* - * mmap path and of->mutex are prone to triggering spurious lockdep - * warnings and we don't want to add spurious locking dependency - * between the two. Check whether mmap is actually implemented - * without grabbing @of->mutex by testing HAS_MMAP flag. See the - * comment in kernfs_file_open() for more details. - */ - if (!(of->kn->flags & KERNFS_HAS_MMAP)) - return -ENODEV; - mutex_lock(&of->mutex); rc = -ENODEV; @@ -475,7 +468,10 @@ goto out_unlock; ops = kernfs_ops(of->kn); + if (ops->mmap) + rc = ops->mmap(of, vma); + if (rc) + goto out_put; - rc = ops->mmap(of, vma); /* * PowerPC's pci_mmap of legacy_mem uses shmem_zero_setup() --- linux-3.14/fs/sysfs/file.c.old 2014-03-31 05:40:15.000000000 +0200 +++ linux-3.14/fs/sysfs/file.c 2014-04-19 11:18:53.296366182 +0200 @@ -141,7 +141,10 @@ { struct bin_attribute *battr = of->kn->priv; struct kobject *kobj = of->kn->parent->priv; - + + if (!battr->mmap) + return -ENODEV; + return battr->mmap(of->file, kobj, battr, vma); } @@ -194,11 +197,6 @@ 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, }; @@ -234,9 +232,7 @@ } else { struct bin_attribute *battr = (void *)attr; - if (battr->mmap) - ops = &sysfs_bin_kfops_mmap; - else if (battr->read && battr->write) + if ((battr->read && battr->write) || battr->mmap) ops = &sysfs_bin_kfops_rw; else if (battr->read) ops = &sysfs_bin_kfops_ro;