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.h47
1 files changed, 29 insertions, 18 deletions
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h
index 4d3f0d1aec73..014cc564d1c4 100644
--- a/include/linux/debugfs.h
+++ b/include/linux/debugfs.h
@@ -52,7 +52,8 @@ extern struct srcu_struct debugfs_srcu;
52 * Must only be called under the protection established by 52 * Must only be called under the protection established by
53 * debugfs_use_file_start(). 53 * debugfs_use_file_start().
54 */ 54 */
55static inline const struct file_operations *debugfs_real_fops(struct file *filp) 55static inline const struct file_operations *
56debugfs_real_fops(const struct file *filp)
56 __must_hold(&debugfs_srcu) 57 __must_hold(&debugfs_srcu)
57{ 58{
58 /* 59 /*
@@ -62,6 +63,21 @@ static inline const struct file_operations *debugfs_real_fops(struct file *filp)
62 return filp->f_path.dentry->d_fsdata; 63 return filp->f_path.dentry->d_fsdata;
63} 64}
64 65
66#define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \
67static int __fops ## _open(struct inode *inode, struct file *file) \
68{ \
69 __simple_attr_check_format(__fmt, 0ull); \
70 return simple_attr_open(inode, file, __get, __set, __fmt); \
71} \
72static const struct file_operations __fops = { \
73 .owner = THIS_MODULE, \
74 .open = __fops ## _open, \
75 .release = simple_attr_release, \
76 .read = debugfs_attr_read, \
77 .write = debugfs_attr_write, \
78 .llseek = generic_file_llseek, \
79}
80
65#if defined(CONFIG_DEBUG_FS) 81#if defined(CONFIG_DEBUG_FS)
66 82
67struct dentry *debugfs_create_file(const char *name, umode_t mode, 83struct dentry *debugfs_create_file(const char *name, umode_t mode,
@@ -99,21 +115,6 @@ ssize_t debugfs_attr_read(struct file *file, char __user *buf,
99ssize_t debugfs_attr_write(struct file *file, const char __user *buf, 115ssize_t debugfs_attr_write(struct file *file, const char __user *buf,
100 size_t len, loff_t *ppos); 116 size_t len, loff_t *ppos);
101 117
102#define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \
103static int __fops ## _open(struct inode *inode, struct file *file) \
104{ \
105 __simple_attr_check_format(__fmt, 0ull); \
106 return simple_attr_open(inode, file, __get, __set, __fmt); \
107} \
108static const struct file_operations __fops = { \
109 .owner = THIS_MODULE, \
110 .open = __fops ## _open, \
111 .release = simple_attr_release, \
112 .read = debugfs_attr_read, \
113 .write = debugfs_attr_write, \
114 .llseek = generic_file_llseek, \
115}
116
117struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, 118struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
118 struct dentry *new_dir, const char *new_name); 119 struct dentry *new_dir, const char *new_name);
119 120
@@ -233,8 +234,18 @@ static inline void debugfs_use_file_finish(int srcu_idx)
233 __releases(&debugfs_srcu) 234 __releases(&debugfs_srcu)
234{ } 235{ }
235 236
236#define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \ 237static inline ssize_t debugfs_attr_read(struct file *file, char __user *buf,
237 static const struct file_operations __fops = { 0 } 238 size_t len, loff_t *ppos)
239{
240 return -ENODEV;
241}
242
243static inline ssize_t debugfs_attr_write(struct file *file,
244 const char __user *buf,
245 size_t len, loff_t *ppos)
246{
247 return -ENODEV;
248}
238 249
239static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, 250static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
240 struct dentry *new_dir, char *new_name) 251 struct dentry *new_dir, char *new_name)