diff options
Diffstat (limited to 'include/linux/debugfs.h')
-rw-r--r-- | include/linux/debugfs.h | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index 981e53ab84e8..1438e2322d5c 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h | |||
@@ -19,9 +19,11 @@ | |||
19 | #include <linux/seq_file.h> | 19 | #include <linux/seq_file.h> |
20 | 20 | ||
21 | #include <linux/types.h> | 21 | #include <linux/types.h> |
22 | #include <linux/compiler.h> | ||
22 | 23 | ||
23 | struct device; | 24 | struct device; |
24 | struct file_operations; | 25 | struct file_operations; |
26 | struct srcu_struct; | ||
25 | 27 | ||
26 | struct debugfs_blob_wrapper { | 28 | struct debugfs_blob_wrapper { |
27 | void *data; | 29 | void *data; |
@@ -41,14 +43,16 @@ struct debugfs_regset32 { | |||
41 | 43 | ||
42 | extern struct dentry *arch_debugfs_dir; | 44 | extern struct dentry *arch_debugfs_dir; |
43 | 45 | ||
44 | #if defined(CONFIG_DEBUG_FS) | 46 | extern struct srcu_struct debugfs_srcu; |
45 | 47 | ||
46 | /* declared over in file.c */ | 48 | #if defined(CONFIG_DEBUG_FS) |
47 | extern const struct file_operations debugfs_file_operations; | ||
48 | 49 | ||
49 | struct dentry *debugfs_create_file(const char *name, umode_t mode, | 50 | struct dentry *debugfs_create_file(const char *name, umode_t mode, |
50 | struct dentry *parent, void *data, | 51 | struct dentry *parent, void *data, |
51 | const struct file_operations *fops); | 52 | const struct file_operations *fops); |
53 | struct dentry *debugfs_create_file_unsafe(const char *name, umode_t mode, | ||
54 | struct dentry *parent, void *data, | ||
55 | const struct file_operations *fops); | ||
52 | 56 | ||
53 | struct dentry *debugfs_create_file_size(const char *name, umode_t mode, | 57 | struct dentry *debugfs_create_file_size(const char *name, umode_t mode, |
54 | struct dentry *parent, void *data, | 58 | struct dentry *parent, void *data, |
@@ -68,6 +72,31 @@ struct dentry *debugfs_create_automount(const char *name, | |||
68 | void debugfs_remove(struct dentry *dentry); | 72 | void debugfs_remove(struct dentry *dentry); |
69 | void debugfs_remove_recursive(struct dentry *dentry); | 73 | void debugfs_remove_recursive(struct dentry *dentry); |
70 | 74 | ||
75 | int debugfs_use_file_start(const struct dentry *dentry, int *srcu_idx) | ||
76 | __acquires(&debugfs_srcu); | ||
77 | |||
78 | void debugfs_use_file_finish(int srcu_idx) __releases(&debugfs_srcu); | ||
79 | |||
80 | ssize_t debugfs_attr_read(struct file *file, char __user *buf, | ||
81 | size_t len, loff_t *ppos); | ||
82 | ssize_t debugfs_attr_write(struct file *file, const char __user *buf, | ||
83 | size_t len, loff_t *ppos); | ||
84 | |||
85 | #define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \ | ||
86 | static int __fops ## _open(struct inode *inode, struct file *file) \ | ||
87 | { \ | ||
88 | __simple_attr_check_format(__fmt, 0ull); \ | ||
89 | return simple_attr_open(inode, file, __get, __set, __fmt); \ | ||
90 | } \ | ||
91 | static const struct file_operations __fops = { \ | ||
92 | .owner = THIS_MODULE, \ | ||
93 | .open = __fops ## _open, \ | ||
94 | .release = simple_attr_release, \ | ||
95 | .read = debugfs_attr_read, \ | ||
96 | .write = debugfs_attr_write, \ | ||
97 | .llseek = generic_file_llseek, \ | ||
98 | } | ||
99 | |||
71 | struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, | 100 | struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, |
72 | struct dentry *new_dir, const char *new_name); | 101 | struct dentry *new_dir, const char *new_name); |
73 | 102 | ||
@@ -176,6 +205,20 @@ static inline void debugfs_remove(struct dentry *dentry) | |||
176 | static inline void debugfs_remove_recursive(struct dentry *dentry) | 205 | static inline void debugfs_remove_recursive(struct dentry *dentry) |
177 | { } | 206 | { } |
178 | 207 | ||
208 | static inline int debugfs_use_file_start(const struct dentry *dentry, | ||
209 | int *srcu_idx) | ||
210 | __acquires(&debugfs_srcu) | ||
211 | { | ||
212 | return 0; | ||
213 | } | ||
214 | |||
215 | static inline void debugfs_use_file_finish(int srcu_idx) | ||
216 | __releases(&debugfs_srcu) | ||
217 | { } | ||
218 | |||
219 | #define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \ | ||
220 | static const struct file_operations __fops = { 0 } | ||
221 | |||
179 | static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, | 222 | static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, |
180 | struct dentry *new_dir, char *new_name) | 223 | struct dentry *new_dir, char *new_name) |
181 | { | 224 | { |