diff options
author | Christian Lamparter <chunkeey@googlemail.com> | 2016-09-17 15:43:01 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-09-21 06:13:31 -0400 |
commit | 86f0e06767dda7863d6d2a8f0b3b857e6ea876a0 (patch) | |
tree | 0bba8aec84b2143fa932cc40e4ea8738d859463a /include/linux/debugfs.h | |
parent | 2f5bb02ff22414ce156cacb163dd594b017af357 (diff) |
debugfs: introduce a public file_operations accessor
This patch introduces an accessor which can be used
by the users of debugfs (drivers, fs, ...) to get the
original file_operations struct. It also removes the
REAL_FOPS_DEREF macro in file.c and converts the code
to use the public version.
Previously, REAL_FOPS_DEREF was only available within
the file.c of debugfs. But having a public getter
available for debugfs users is important as some
drivers (carl9170 and b43) use the pointer of the
original file_operations in conjunction with container_of()
within their debugfs implementations.
Reviewed-by: Nicolai Stange <nicstange@gmail.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Cc: stable <stable@vger.kernel.org> # 4.7+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/debugfs.h')
-rw-r--r-- | include/linux/debugfs.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index 1438e2322d5c..4d3f0d1aec73 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h | |||
@@ -45,6 +45,23 @@ extern struct dentry *arch_debugfs_dir; | |||
45 | 45 | ||
46 | extern struct srcu_struct debugfs_srcu; | 46 | extern struct srcu_struct debugfs_srcu; |
47 | 47 | ||
48 | /** | ||
49 | * debugfs_real_fops - getter for the real file operation | ||
50 | * @filp: a pointer to a struct file | ||
51 | * | ||
52 | * Must only be called under the protection established by | ||
53 | * debugfs_use_file_start(). | ||
54 | */ | ||
55 | static inline const struct file_operations *debugfs_real_fops(struct file *filp) | ||
56 | __must_hold(&debugfs_srcu) | ||
57 | { | ||
58 | /* | ||
59 | * Neither the pointer to the struct file_operations, nor its | ||
60 | * contents ever change -- srcu_dereference() is not needed here. | ||
61 | */ | ||
62 | return filp->f_path.dentry->d_fsdata; | ||
63 | } | ||
64 | |||
48 | #if defined(CONFIG_DEBUG_FS) | 65 | #if defined(CONFIG_DEBUG_FS) |
49 | 66 | ||
50 | struct dentry *debugfs_create_file(const char *name, umode_t mode, | 67 | struct dentry *debugfs_create_file(const char *name, umode_t mode, |