]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * debugfs.h - a tiny little debug file system | |
3 | * | |
4 | * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com> | |
5 | * Copyright (C) 2004 IBM Inc. | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or | |
8 | * modify it under the terms of the GNU General Public License version | |
9 | * 2 as published by the Free Software Foundation. | |
10 | * | |
11 | * debugfs is for people to use instead of /proc or /sys. | |
55dff495 | 12 | * See Documentation/DocBook/filesystems for more details. |
1da177e4 LT |
13 | */ |
14 | ||
15 | #ifndef _DEBUGFS_H_ | |
16 | #define _DEBUGFS_H_ | |
17 | ||
18 | #include <linux/fs.h> | |
1a087c6a | 19 | #include <linux/seq_file.h> |
1da177e4 | 20 | |
a7a76cef | 21 | #include <linux/types.h> |
49d200de | 22 | #include <linux/compiler.h> |
a7a76cef | 23 | |
f30d0a81 | 24 | struct device; |
a7a76cef | 25 | struct file_operations; |
49d200de | 26 | struct srcu_struct; |
a7a76cef | 27 | |
dd308bc3 ME |
28 | struct debugfs_blob_wrapper { |
29 | void *data; | |
30 | unsigned long size; | |
31 | }; | |
32 | ||
1a087c6a AR |
33 | struct debugfs_reg32 { |
34 | char *name; | |
35 | unsigned long offset; | |
36 | }; | |
37 | ||
38 | struct debugfs_regset32 { | |
833d6e01 | 39 | const struct debugfs_reg32 *regs; |
1a087c6a AR |
40 | int nregs; |
41 | void __iomem *base; | |
42 | }; | |
43 | ||
ae79cdaa | 44 | extern struct dentry *arch_debugfs_dir; |
45 | ||
49d200de NS |
46 | extern struct srcu_struct debugfs_srcu; |
47 | ||
1da177e4 | 48 | #if defined(CONFIG_DEBUG_FS) |
3634634e | 49 | |
f4ae40a6 | 50 | struct dentry *debugfs_create_file(const char *name, umode_t mode, |
1da177e4 | 51 | struct dentry *parent, void *data, |
99ac48f5 | 52 | const struct file_operations *fops); |
1da177e4 | 53 | |
e59b4e91 DH |
54 | struct dentry *debugfs_create_file_size(const char *name, umode_t mode, |
55 | struct dentry *parent, void *data, | |
56 | const struct file_operations *fops, | |
57 | loff_t file_size); | |
58 | ||
1da177e4 LT |
59 | struct dentry *debugfs_create_dir(const char *name, struct dentry *parent); |
60 | ||
66f54963 PO |
61 | struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, |
62 | const char *dest); | |
63 | ||
77b3da6e AV |
64 | struct dentry *debugfs_create_automount(const char *name, |
65 | struct dentry *parent, | |
66 | struct vfsmount *(*f)(void *), | |
67 | void *data); | |
68 | ||
1da177e4 | 69 | void debugfs_remove(struct dentry *dentry); |
9505e637 | 70 | void debugfs_remove_recursive(struct dentry *dentry); |
1da177e4 | 71 | |
49d200de NS |
72 | int debugfs_use_file_start(const struct dentry *dentry, int *srcu_idx) |
73 | __acquires(&debugfs_srcu); | |
74 | ||
75 | void debugfs_use_file_finish(int srcu_idx) __releases(&debugfs_srcu); | |
76 | ||
cfc94cdf JK |
77 | struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, |
78 | struct dentry *new_dir, const char *new_name); | |
79 | ||
f4ae40a6 | 80 | struct dentry *debugfs_create_u8(const char *name, umode_t mode, |
1da177e4 | 81 | struct dentry *parent, u8 *value); |
f4ae40a6 | 82 | struct dentry *debugfs_create_u16(const char *name, umode_t mode, |
1da177e4 | 83 | struct dentry *parent, u16 *value); |
f4ae40a6 | 84 | struct dentry *debugfs_create_u32(const char *name, umode_t mode, |
1da177e4 | 85 | struct dentry *parent, u32 *value); |
f4ae40a6 | 86 | struct dentry *debugfs_create_u64(const char *name, umode_t mode, |
8447891f | 87 | struct dentry *parent, u64 *value); |
c23fe831 VK |
88 | struct dentry *debugfs_create_ulong(const char *name, umode_t mode, |
89 | struct dentry *parent, unsigned long *value); | |
f4ae40a6 | 90 | struct dentry *debugfs_create_x8(const char *name, umode_t mode, |
2ebefc50 | 91 | struct dentry *parent, u8 *value); |
f4ae40a6 | 92 | struct dentry *debugfs_create_x16(const char *name, umode_t mode, |
2ebefc50 | 93 | struct dentry *parent, u16 *value); |
f4ae40a6 | 94 | struct dentry *debugfs_create_x32(const char *name, umode_t mode, |
2ebefc50 | 95 | struct dentry *parent, u32 *value); |
f4ae40a6 | 96 | struct dentry *debugfs_create_x64(const char *name, umode_t mode, |
15b0beaa | 97 | struct dentry *parent, u64 *value); |
f4ae40a6 | 98 | struct dentry *debugfs_create_size_t(const char *name, umode_t mode, |
5e078787 | 99 | struct dentry *parent, size_t *value); |
3a76e5e0 SJ |
100 | struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode, |
101 | struct dentry *parent, atomic_t *value); | |
f4ae40a6 | 102 | struct dentry *debugfs_create_bool(const char *name, umode_t mode, |
621a5f7a | 103 | struct dentry *parent, bool *value); |
1da177e4 | 104 | |
f4ae40a6 | 105 | struct dentry *debugfs_create_blob(const char *name, umode_t mode, |
dd308bc3 ME |
106 | struct dentry *parent, |
107 | struct debugfs_blob_wrapper *blob); | |
c0f92ba9 | 108 | |
88187398 | 109 | struct dentry *debugfs_create_regset32(const char *name, umode_t mode, |
1a087c6a AR |
110 | struct dentry *parent, |
111 | struct debugfs_regset32 *regset); | |
112 | ||
9761536e JP |
113 | void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs, |
114 | int nregs, void __iomem *base, char *prefix); | |
1a087c6a | 115 | |
9fe2a701 SV |
116 | struct dentry *debugfs_create_u32_array(const char *name, umode_t mode, |
117 | struct dentry *parent, | |
118 | u32 *array, u32 elements); | |
119 | ||
98210b7f AS |
120 | struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name, |
121 | struct dentry *parent, | |
122 | int (*read_fn)(struct seq_file *s, | |
123 | void *data)); | |
124 | ||
c0f92ba9 FW |
125 | bool debugfs_initialized(void); |
126 | ||
0642ef6f RF |
127 | ssize_t debugfs_read_file_bool(struct file *file, char __user *user_buf, |
128 | size_t count, loff_t *ppos); | |
129 | ||
130 | ssize_t debugfs_write_file_bool(struct file *file, const char __user *user_buf, | |
131 | size_t count, loff_t *ppos); | |
132 | ||
1da177e4 | 133 | #else |
a7a76cef RD |
134 | |
135 | #include <linux/err.h> | |
136 | ||
98210b7f | 137 | /* |
1da177e4 LT |
138 | * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled |
139 | * so users have a chance to detect if there was a real error or not. We don't | |
140 | * want to duplicate the design decision mistakes of procfs and devfs again. | |
141 | */ | |
142 | ||
f4ae40a6 | 143 | static inline struct dentry *debugfs_create_file(const char *name, umode_t mode, |
bde11d79 JD |
144 | struct dentry *parent, void *data, |
145 | const struct file_operations *fops) | |
1da177e4 LT |
146 | { |
147 | return ERR_PTR(-ENODEV); | |
148 | } | |
149 | ||
e59b4e91 DH |
150 | static inline struct dentry *debugfs_create_file_size(const char *name, umode_t mode, |
151 | struct dentry *parent, void *data, | |
152 | const struct file_operations *fops, | |
153 | loff_t file_size) | |
154 | { | |
155 | return ERR_PTR(-ENODEV); | |
156 | } | |
157 | ||
1da177e4 LT |
158 | static inline struct dentry *debugfs_create_dir(const char *name, |
159 | struct dentry *parent) | |
160 | { | |
161 | return ERR_PTR(-ENODEV); | |
162 | } | |
163 | ||
66f54963 PO |
164 | static inline struct dentry *debugfs_create_symlink(const char *name, |
165 | struct dentry *parent, | |
166 | const char *dest) | |
167 | { | |
168 | return ERR_PTR(-ENODEV); | |
169 | } | |
170 | ||
94e1dec7 JW |
171 | static inline struct dentry *debugfs_create_automount(const char *name, |
172 | struct dentry *parent, | |
173 | struct vfsmount *(*f)(void *), | |
174 | void *data) | |
175 | { | |
176 | return ERR_PTR(-ENODEV); | |
177 | } | |
178 | ||
1da177e4 LT |
179 | static inline void debugfs_remove(struct dentry *dentry) |
180 | { } | |
181 | ||
9505e637 HS |
182 | static inline void debugfs_remove_recursive(struct dentry *dentry) |
183 | { } | |
184 | ||
49d200de NS |
185 | static inline int debugfs_use_file_start(const struct dentry *dentry, |
186 | int *srcu_idx) | |
187 | __acquires(&debugfs_srcu) | |
188 | { | |
189 | return 0; | |
190 | } | |
191 | ||
192 | static inline void debugfs_use_file_finish(int srcu_idx) | |
193 | __releases(&debugfs_srcu) | |
194 | { } | |
195 | ||
cfc94cdf JK |
196 | static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, |
197 | struct dentry *new_dir, char *new_name) | |
198 | { | |
199 | return ERR_PTR(-ENODEV); | |
200 | } | |
201 | ||
f4ae40a6 | 202 | static inline struct dentry *debugfs_create_u8(const char *name, umode_t mode, |
1da177e4 LT |
203 | struct dentry *parent, |
204 | u8 *value) | |
205 | { | |
206 | return ERR_PTR(-ENODEV); | |
207 | } | |
208 | ||
f4ae40a6 | 209 | static inline struct dentry *debugfs_create_u16(const char *name, umode_t mode, |
1da177e4 | 210 | struct dentry *parent, |
7b558637 | 211 | u16 *value) |
1da177e4 LT |
212 | { |
213 | return ERR_PTR(-ENODEV); | |
214 | } | |
215 | ||
f4ae40a6 | 216 | static inline struct dentry *debugfs_create_u32(const char *name, umode_t mode, |
1da177e4 | 217 | struct dentry *parent, |
7b558637 | 218 | u32 *value) |
1da177e4 LT |
219 | { |
220 | return ERR_PTR(-ENODEV); | |
221 | } | |
222 | ||
f4ae40a6 | 223 | static inline struct dentry *debugfs_create_u64(const char *name, umode_t mode, |
8447891f ME |
224 | struct dentry *parent, |
225 | u64 *value) | |
226 | { | |
227 | return ERR_PTR(-ENODEV); | |
228 | } | |
229 | ||
f4ae40a6 | 230 | static inline struct dentry *debugfs_create_x8(const char *name, umode_t mode, |
2ebefc50 RG |
231 | struct dentry *parent, |
232 | u8 *value) | |
233 | { | |
234 | return ERR_PTR(-ENODEV); | |
235 | } | |
236 | ||
f4ae40a6 | 237 | static inline struct dentry *debugfs_create_x16(const char *name, umode_t mode, |
2ebefc50 RG |
238 | struct dentry *parent, |
239 | u16 *value) | |
240 | { | |
241 | return ERR_PTR(-ENODEV); | |
242 | } | |
243 | ||
f4ae40a6 | 244 | static inline struct dentry *debugfs_create_x32(const char *name, umode_t mode, |
2ebefc50 RG |
245 | struct dentry *parent, |
246 | u32 *value) | |
247 | { | |
248 | return ERR_PTR(-ENODEV); | |
249 | } | |
250 | ||
3159269e JB |
251 | static inline struct dentry *debugfs_create_x64(const char *name, umode_t mode, |
252 | struct dentry *parent, | |
253 | u64 *value) | |
254 | { | |
255 | return ERR_PTR(-ENODEV); | |
256 | } | |
257 | ||
f4ae40a6 | 258 | static inline struct dentry *debugfs_create_size_t(const char *name, umode_t mode, |
8adb711f IPG |
259 | struct dentry *parent, |
260 | size_t *value) | |
261 | { | |
262 | return ERR_PTR(-ENODEV); | |
263 | } | |
264 | ||
5b880214 WY |
265 | static inline struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode, |
266 | struct dentry *parent, atomic_t *value) | |
267 | { | |
268 | return ERR_PTR(-ENODEV); | |
269 | } | |
270 | ||
f4ae40a6 | 271 | static inline struct dentry *debugfs_create_bool(const char *name, umode_t mode, |
1da177e4 | 272 | struct dentry *parent, |
621a5f7a | 273 | bool *value) |
1da177e4 LT |
274 | { |
275 | return ERR_PTR(-ENODEV); | |
276 | } | |
277 | ||
f4ae40a6 | 278 | static inline struct dentry *debugfs_create_blob(const char *name, umode_t mode, |
dd308bc3 ME |
279 | struct dentry *parent, |
280 | struct debugfs_blob_wrapper *blob) | |
281 | { | |
282 | return ERR_PTR(-ENODEV); | |
283 | } | |
284 | ||
1a087c6a | 285 | static inline struct dentry *debugfs_create_regset32(const char *name, |
88187398 | 286 | umode_t mode, struct dentry *parent, |
1a087c6a AR |
287 | struct debugfs_regset32 *regset) |
288 | { | |
289 | return ERR_PTR(-ENODEV); | |
290 | } | |
291 | ||
9761536e | 292 | static inline void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs, |
5b880214 WY |
293 | int nregs, void __iomem *base, char *prefix) |
294 | { | |
5b880214 WY |
295 | } |
296 | ||
c0f92ba9 FW |
297 | static inline bool debugfs_initialized(void) |
298 | { | |
299 | return false; | |
300 | } | |
301 | ||
9fe2a701 SV |
302 | static inline struct dentry *debugfs_create_u32_array(const char *name, umode_t mode, |
303 | struct dentry *parent, | |
304 | u32 *array, u32 elements) | |
305 | { | |
306 | return ERR_PTR(-ENODEV); | |
307 | } | |
308 | ||
98210b7f AS |
309 | static inline struct dentry *debugfs_create_devm_seqfile(struct device *dev, |
310 | const char *name, | |
311 | struct dentry *parent, | |
312 | int (*read_fn)(struct seq_file *s, | |
313 | void *data)) | |
314 | { | |
315 | return ERR_PTR(-ENODEV); | |
316 | } | |
317 | ||
0642ef6f RF |
318 | static inline ssize_t debugfs_read_file_bool(struct file *file, |
319 | char __user *user_buf, | |
320 | size_t count, loff_t *ppos) | |
321 | { | |
322 | return -ENODEV; | |
323 | } | |
324 | ||
325 | static inline ssize_t debugfs_write_file_bool(struct file *file, | |
326 | const char __user *user_buf, | |
327 | size_t count, loff_t *ppos) | |
328 | { | |
329 | return -ENODEV; | |
330 | } | |
331 | ||
1da177e4 LT |
332 | #endif |
333 | ||
334 | #endif |