aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/debugfs.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/debugfs.h')
-rw-r--r--include/linux/debugfs.h49
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
23struct device; 24struct device;
24struct file_operations; 25struct file_operations;
26struct srcu_struct;
25 27
26struct debugfs_blob_wrapper { 28struct debugfs_blob_wrapper {
27 void *data; 29 void *data;
@@ -41,14 +43,16 @@ struct debugfs_regset32 {
41 43
42extern struct dentry *arch_debugfs_dir; 44extern struct dentry *arch_debugfs_dir;
43 45
44#if defined(CONFIG_DEBUG_FS) 46extern struct srcu_struct debugfs_srcu;
45 47
46/* declared over in file.c */ 48#if defined(CONFIG_DEBUG_FS)
47extern const struct file_operations debugfs_file_operations;
48 49
49struct dentry *debugfs_create_file(const char *name, umode_t mode, 50struct 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);
53struct 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
53struct dentry *debugfs_create_file_size(const char *name, umode_t mode, 57struct 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,
68void debugfs_remove(struct dentry *dentry); 72void debugfs_remove(struct dentry *dentry);
69void debugfs_remove_recursive(struct dentry *dentry); 73void debugfs_remove_recursive(struct dentry *dentry);
70 74
75int debugfs_use_file_start(const struct dentry *dentry, int *srcu_idx)
76 __acquires(&debugfs_srcu);
77
78void debugfs_use_file_finish(int srcu_idx) __releases(&debugfs_srcu);
79
80ssize_t debugfs_attr_read(struct file *file, char __user *buf,
81 size_t len, loff_t *ppos);
82ssize_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) \
86static 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} \
91static 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
71struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, 100struct 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)
176static inline void debugfs_remove_recursive(struct dentry *dentry) 205static inline void debugfs_remove_recursive(struct dentry *dentry)
177{ } 206{ }
178 207
208static inline int debugfs_use_file_start(const struct dentry *dentry,
209 int *srcu_idx)
210 __acquires(&debugfs_srcu)
211{
212 return 0;
213}
214
215static 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
179static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, 222static 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{