diff options
Diffstat (limited to 'fs/sysfs/file.c')
-rw-r--r-- | fs/sysfs/file.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index b94f93685093..35e7d08fe629 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -609,7 +609,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file) | |||
609 | struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; | 609 | struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; |
610 | struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; | 610 | struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; |
611 | struct sysfs_open_file *of; | 611 | struct sysfs_open_file *of; |
612 | bool has_read, has_write, has_mmap; | 612 | bool has_read, has_write; |
613 | int error = -EACCES; | 613 | int error = -EACCES; |
614 | 614 | ||
615 | /* need attr_sd for attr and ops, its parent for kobj */ | 615 | /* need attr_sd for attr and ops, its parent for kobj */ |
@@ -621,7 +621,6 @@ static int sysfs_open_file(struct inode *inode, struct file *file) | |||
621 | 621 | ||
622 | has_read = battr->read || battr->mmap; | 622 | has_read = battr->read || battr->mmap; |
623 | has_write = battr->write || battr->mmap; | 623 | has_write = battr->write || battr->mmap; |
624 | has_mmap = battr->mmap; | ||
625 | } else { | 624 | } else { |
626 | const struct sysfs_ops *ops = sysfs_file_ops(attr_sd); | 625 | const struct sysfs_ops *ops = sysfs_file_ops(attr_sd); |
627 | 626 | ||
@@ -633,7 +632,6 @@ static int sysfs_open_file(struct inode *inode, struct file *file) | |||
633 | 632 | ||
634 | has_read = ops->show; | 633 | has_read = ops->show; |
635 | has_write = ops->store; | 634 | has_write = ops->store; |
636 | has_mmap = false; | ||
637 | } | 635 | } |
638 | 636 | ||
639 | /* check perms and supported operations */ | 637 | /* check perms and supported operations */ |
@@ -661,9 +659,9 @@ static int sysfs_open_file(struct inode *inode, struct file *file) | |||
661 | * open file has a separate mutex, it's okay as long as those don't | 659 | * open file has a separate mutex, it's okay as long as those don't |
662 | * happen on the same file. At this point, we can't easily give | 660 | * happen on the same file. At this point, we can't easily give |
663 | * each file a separate locking class. Let's differentiate on | 661 | * each file a separate locking class. Let's differentiate on |
664 | * whether the file has mmap or not for now. | 662 | * whether the file is bin or not for now. |
665 | */ | 663 | */ |
666 | if (has_mmap) | 664 | if (sysfs_is_bin(attr_sd)) |
667 | mutex_init(&of->mutex); | 665 | mutex_init(&of->mutex); |
668 | else | 666 | else |
669 | mutex_init(&of->mutex); | 667 | mutex_init(&of->mutex); |