.. | .. |
---|
35 | 35 | const struct debugfs_reg32 *regs; |
---|
36 | 36 | int nregs; |
---|
37 | 37 | void __iomem *base; |
---|
| 38 | + struct device *dev; /* Optional device for Runtime PM */ |
---|
| 39 | +}; |
---|
| 40 | + |
---|
| 41 | +struct debugfs_u32_array { |
---|
| 42 | + u32 *array; |
---|
| 43 | + u32 n_elements; |
---|
38 | 44 | }; |
---|
39 | 45 | |
---|
40 | 46 | extern struct dentry *arch_debugfs_dir; |
---|
41 | 47 | |
---|
42 | | -#define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \ |
---|
| 48 | +#define DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, __is_signed) \ |
---|
43 | 49 | static int __fops ## _open(struct inode *inode, struct file *file) \ |
---|
44 | 50 | { \ |
---|
45 | 51 | __simple_attr_check_format(__fmt, 0ull); \ |
---|
.. | .. |
---|
50 | 56 | .open = __fops ## _open, \ |
---|
51 | 57 | .release = simple_attr_release, \ |
---|
52 | 58 | .read = debugfs_attr_read, \ |
---|
53 | | - .write = debugfs_attr_write, \ |
---|
| 59 | + .write = (__is_signed) ? debugfs_attr_write_signed : debugfs_attr_write, \ |
---|
54 | 60 | .llseek = no_llseek, \ |
---|
55 | 61 | } |
---|
| 62 | + |
---|
| 63 | +#define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \ |
---|
| 64 | + DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, false) |
---|
| 65 | + |
---|
| 66 | +#define DEFINE_DEBUGFS_ATTRIBUTE_SIGNED(__fops, __get, __set, __fmt) \ |
---|
| 67 | + DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, true) |
---|
56 | 68 | |
---|
57 | 69 | typedef struct vfsmount *(*debugfs_automount_t)(struct dentry *, void *); |
---|
58 | 70 | |
---|
.. | .. |
---|
67 | 79 | struct dentry *parent, void *data, |
---|
68 | 80 | const struct file_operations *fops); |
---|
69 | 81 | |
---|
70 | | -struct dentry *debugfs_create_file_size(const char *name, umode_t mode, |
---|
71 | | - struct dentry *parent, void *data, |
---|
72 | | - const struct file_operations *fops, |
---|
73 | | - loff_t file_size); |
---|
| 82 | +void debugfs_create_file_size(const char *name, umode_t mode, |
---|
| 83 | + struct dentry *parent, void *data, |
---|
| 84 | + const struct file_operations *fops, |
---|
| 85 | + loff_t file_size); |
---|
74 | 86 | |
---|
75 | 87 | struct dentry *debugfs_create_dir(const char *name, struct dentry *parent); |
---|
76 | 88 | |
---|
.. | .. |
---|
83 | 95 | void *data); |
---|
84 | 96 | |
---|
85 | 97 | void debugfs_remove(struct dentry *dentry); |
---|
86 | | -void debugfs_remove_recursive(struct dentry *dentry); |
---|
| 98 | +#define debugfs_remove_recursive debugfs_remove |
---|
| 99 | + |
---|
| 100 | +void debugfs_lookup_and_remove(const char *name, struct dentry *parent); |
---|
87 | 101 | |
---|
88 | 102 | const struct file_operations *debugfs_real_fops(const struct file *filp); |
---|
89 | 103 | |
---|
.. | .. |
---|
94 | 108 | size_t len, loff_t *ppos); |
---|
95 | 109 | ssize_t debugfs_attr_write(struct file *file, const char __user *buf, |
---|
96 | 110 | size_t len, loff_t *ppos); |
---|
| 111 | +ssize_t debugfs_attr_write_signed(struct file *file, const char __user *buf, |
---|
| 112 | + size_t len, loff_t *ppos); |
---|
97 | 113 | |
---|
98 | 114 | struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, |
---|
99 | 115 | struct dentry *new_dir, const char *new_name); |
---|
100 | 116 | |
---|
101 | | -struct dentry *debugfs_create_u8(const char *name, umode_t mode, |
---|
102 | | - struct dentry *parent, u8 *value); |
---|
103 | | -struct dentry *debugfs_create_u16(const char *name, umode_t mode, |
---|
104 | | - struct dentry *parent, u16 *value); |
---|
105 | | -struct dentry *debugfs_create_u32(const char *name, umode_t mode, |
---|
106 | | - struct dentry *parent, u32 *value); |
---|
107 | | -struct dentry *debugfs_create_u64(const char *name, umode_t mode, |
---|
108 | | - struct dentry *parent, u64 *value); |
---|
| 117 | +void debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent, |
---|
| 118 | + u8 *value); |
---|
| 119 | +void debugfs_create_u16(const char *name, umode_t mode, struct dentry *parent, |
---|
| 120 | + u16 *value); |
---|
| 121 | +void debugfs_create_u32(const char *name, umode_t mode, struct dentry *parent, |
---|
| 122 | + u32 *value); |
---|
| 123 | +void debugfs_create_u64(const char *name, umode_t mode, struct dentry *parent, |
---|
| 124 | + u64 *value); |
---|
109 | 125 | struct dentry *debugfs_create_ulong(const char *name, umode_t mode, |
---|
110 | 126 | struct dentry *parent, unsigned long *value); |
---|
111 | | -struct dentry *debugfs_create_x8(const char *name, umode_t mode, |
---|
112 | | - struct dentry *parent, u8 *value); |
---|
113 | | -struct dentry *debugfs_create_x16(const char *name, umode_t mode, |
---|
114 | | - struct dentry *parent, u16 *value); |
---|
115 | | -struct dentry *debugfs_create_x32(const char *name, umode_t mode, |
---|
116 | | - struct dentry *parent, u32 *value); |
---|
117 | | -struct dentry *debugfs_create_x64(const char *name, umode_t mode, |
---|
118 | | - struct dentry *parent, u64 *value); |
---|
119 | | -struct dentry *debugfs_create_size_t(const char *name, umode_t mode, |
---|
120 | | - struct dentry *parent, size_t *value); |
---|
121 | | -struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode, |
---|
122 | | - struct dentry *parent, atomic_t *value); |
---|
| 127 | +void debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent, |
---|
| 128 | + u8 *value); |
---|
| 129 | +void debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent, |
---|
| 130 | + u16 *value); |
---|
| 131 | +void debugfs_create_x32(const char *name, umode_t mode, struct dentry *parent, |
---|
| 132 | + u32 *value); |
---|
| 133 | +void debugfs_create_x64(const char *name, umode_t mode, struct dentry *parent, |
---|
| 134 | + u64 *value); |
---|
| 135 | +void debugfs_create_size_t(const char *name, umode_t mode, |
---|
| 136 | + struct dentry *parent, size_t *value); |
---|
| 137 | +void debugfs_create_atomic_t(const char *name, umode_t mode, |
---|
| 138 | + struct dentry *parent, atomic_t *value); |
---|
123 | 139 | struct dentry *debugfs_create_bool(const char *name, umode_t mode, |
---|
124 | 140 | struct dentry *parent, bool *value); |
---|
125 | 141 | |
---|
.. | .. |
---|
127 | 143 | struct dentry *parent, |
---|
128 | 144 | struct debugfs_blob_wrapper *blob); |
---|
129 | 145 | |
---|
130 | | -struct dentry *debugfs_create_regset32(const char *name, umode_t mode, |
---|
131 | | - struct dentry *parent, |
---|
132 | | - struct debugfs_regset32 *regset); |
---|
| 146 | +void debugfs_create_regset32(const char *name, umode_t mode, |
---|
| 147 | + struct dentry *parent, |
---|
| 148 | + struct debugfs_regset32 *regset); |
---|
133 | 149 | |
---|
134 | 150 | void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs, |
---|
135 | 151 | int nregs, void __iomem *base, char *prefix); |
---|
136 | 152 | |
---|
137 | | -struct dentry *debugfs_create_u32_array(const char *name, umode_t mode, |
---|
138 | | - struct dentry *parent, |
---|
139 | | - u32 *array, u32 elements); |
---|
| 153 | +void debugfs_create_u32_array(const char *name, umode_t mode, |
---|
| 154 | + struct dentry *parent, |
---|
| 155 | + struct debugfs_u32_array *array); |
---|
140 | 156 | |
---|
141 | | -struct dentry *debugfs_create_u32_array_hex(const char *name, umode_t mode, |
---|
142 | | - struct dentry *parent, |
---|
143 | | - u32 *array, u32 elements); |
---|
144 | | - |
---|
145 | | -struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name, |
---|
146 | | - struct dentry *parent, |
---|
147 | | - int (*read_fn)(struct seq_file *s, |
---|
148 | | - void *data)); |
---|
| 157 | +void debugfs_create_devm_seqfile(struct device *dev, const char *name, |
---|
| 158 | + struct dentry *parent, |
---|
| 159 | + int (*read_fn)(struct seq_file *s, void *data)); |
---|
149 | 160 | |
---|
150 | 161 | bool debugfs_initialized(void); |
---|
151 | 162 | |
---|
.. | .. |
---|
186 | 197 | return ERR_PTR(-ENODEV); |
---|
187 | 198 | } |
---|
188 | 199 | |
---|
189 | | -static inline struct dentry *debugfs_create_file_size(const char *name, umode_t mode, |
---|
190 | | - struct dentry *parent, void *data, |
---|
191 | | - const struct file_operations *fops, |
---|
192 | | - loff_t file_size) |
---|
193 | | -{ |
---|
194 | | - return ERR_PTR(-ENODEV); |
---|
195 | | -} |
---|
| 200 | +static inline void debugfs_create_file_size(const char *name, umode_t mode, |
---|
| 201 | + struct dentry *parent, void *data, |
---|
| 202 | + const struct file_operations *fops, |
---|
| 203 | + loff_t file_size) |
---|
| 204 | +{ } |
---|
196 | 205 | |
---|
197 | 206 | static inline struct dentry *debugfs_create_dir(const char *name, |
---|
198 | 207 | struct dentry *parent) |
---|
.. | .. |
---|
221 | 230 | static inline void debugfs_remove_recursive(struct dentry *dentry) |
---|
222 | 231 | { } |
---|
223 | 232 | |
---|
| 233 | +static inline void debugfs_lookup_and_remove(const char *name, |
---|
| 234 | + struct dentry *parent) |
---|
| 235 | +{ } |
---|
| 236 | + |
---|
224 | 237 | const struct file_operations *debugfs_real_fops(const struct file *filp); |
---|
225 | 238 | |
---|
226 | 239 | static inline int debugfs_file_get(struct dentry *dentry) |
---|
.. | .. |
---|
244 | 257 | return -ENODEV; |
---|
245 | 258 | } |
---|
246 | 259 | |
---|
| 260 | +static inline ssize_t debugfs_attr_write_signed(struct file *file, |
---|
| 261 | + const char __user *buf, |
---|
| 262 | + size_t len, loff_t *ppos) |
---|
| 263 | +{ |
---|
| 264 | + return -ENODEV; |
---|
| 265 | +} |
---|
| 266 | + |
---|
247 | 267 | static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, |
---|
248 | 268 | struct dentry *new_dir, char *new_name) |
---|
249 | 269 | { |
---|
250 | 270 | return ERR_PTR(-ENODEV); |
---|
251 | 271 | } |
---|
252 | 272 | |
---|
253 | | -static inline struct dentry *debugfs_create_u8(const char *name, umode_t mode, |
---|
254 | | - struct dentry *parent, |
---|
255 | | - u8 *value) |
---|
256 | | -{ |
---|
257 | | - return ERR_PTR(-ENODEV); |
---|
258 | | -} |
---|
| 273 | +static inline void debugfs_create_u8(const char *name, umode_t mode, |
---|
| 274 | + struct dentry *parent, u8 *value) { } |
---|
259 | 275 | |
---|
260 | | -static inline struct dentry *debugfs_create_u16(const char *name, umode_t mode, |
---|
261 | | - struct dentry *parent, |
---|
262 | | - u16 *value) |
---|
263 | | -{ |
---|
264 | | - return ERR_PTR(-ENODEV); |
---|
265 | | -} |
---|
| 276 | +static inline void debugfs_create_u16(const char *name, umode_t mode, |
---|
| 277 | + struct dentry *parent, u16 *value) { } |
---|
266 | 278 | |
---|
267 | | -static inline struct dentry *debugfs_create_u32(const char *name, umode_t mode, |
---|
268 | | - struct dentry *parent, |
---|
269 | | - u32 *value) |
---|
270 | | -{ |
---|
271 | | - return ERR_PTR(-ENODEV); |
---|
272 | | -} |
---|
| 279 | +static inline void debugfs_create_u32(const char *name, umode_t mode, |
---|
| 280 | + struct dentry *parent, u32 *value) { } |
---|
273 | 281 | |
---|
274 | | -static inline struct dentry *debugfs_create_u64(const char *name, umode_t mode, |
---|
275 | | - struct dentry *parent, |
---|
276 | | - u64 *value) |
---|
277 | | -{ |
---|
278 | | - return ERR_PTR(-ENODEV); |
---|
279 | | -} |
---|
| 282 | +static inline void debugfs_create_u64(const char *name, umode_t mode, |
---|
| 283 | + struct dentry *parent, u64 *value) { } |
---|
280 | 284 | |
---|
281 | 285 | static inline struct dentry *debugfs_create_ulong(const char *name, |
---|
282 | 286 | umode_t mode, |
---|
.. | .. |
---|
286 | 290 | return ERR_PTR(-ENODEV); |
---|
287 | 291 | } |
---|
288 | 292 | |
---|
289 | | -static inline struct dentry *debugfs_create_x8(const char *name, umode_t mode, |
---|
290 | | - struct dentry *parent, |
---|
291 | | - u8 *value) |
---|
292 | | -{ |
---|
293 | | - return ERR_PTR(-ENODEV); |
---|
294 | | -} |
---|
| 293 | +static inline void debugfs_create_x8(const char *name, umode_t mode, |
---|
| 294 | + struct dentry *parent, u8 *value) { } |
---|
295 | 295 | |
---|
296 | | -static inline struct dentry *debugfs_create_x16(const char *name, umode_t mode, |
---|
297 | | - struct dentry *parent, |
---|
298 | | - u16 *value) |
---|
299 | | -{ |
---|
300 | | - return ERR_PTR(-ENODEV); |
---|
301 | | -} |
---|
| 296 | +static inline void debugfs_create_x16(const char *name, umode_t mode, |
---|
| 297 | + struct dentry *parent, u16 *value) { } |
---|
302 | 298 | |
---|
303 | | -static inline struct dentry *debugfs_create_x32(const char *name, umode_t mode, |
---|
304 | | - struct dentry *parent, |
---|
305 | | - u32 *value) |
---|
306 | | -{ |
---|
307 | | - return ERR_PTR(-ENODEV); |
---|
308 | | -} |
---|
| 299 | +static inline void debugfs_create_x32(const char *name, umode_t mode, |
---|
| 300 | + struct dentry *parent, u32 *value) { } |
---|
309 | 301 | |
---|
310 | | -static inline struct dentry *debugfs_create_x64(const char *name, umode_t mode, |
---|
311 | | - struct dentry *parent, |
---|
312 | | - u64 *value) |
---|
313 | | -{ |
---|
314 | | - return ERR_PTR(-ENODEV); |
---|
315 | | -} |
---|
| 302 | +static inline void debugfs_create_x64(const char *name, umode_t mode, |
---|
| 303 | + struct dentry *parent, u64 *value) { } |
---|
316 | 304 | |
---|
317 | | -static inline struct dentry *debugfs_create_size_t(const char *name, umode_t mode, |
---|
318 | | - struct dentry *parent, |
---|
319 | | - size_t *value) |
---|
320 | | -{ |
---|
321 | | - return ERR_PTR(-ENODEV); |
---|
322 | | -} |
---|
| 305 | +static inline void debugfs_create_size_t(const char *name, umode_t mode, |
---|
| 306 | + struct dentry *parent, size_t *value) |
---|
| 307 | +{ } |
---|
323 | 308 | |
---|
324 | | -static inline struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode, |
---|
325 | | - struct dentry *parent, atomic_t *value) |
---|
326 | | -{ |
---|
327 | | - return ERR_PTR(-ENODEV); |
---|
328 | | -} |
---|
| 309 | +static inline void debugfs_create_atomic_t(const char *name, umode_t mode, |
---|
| 310 | + struct dentry *parent, |
---|
| 311 | + atomic_t *value) |
---|
| 312 | +{ } |
---|
329 | 313 | |
---|
330 | 314 | static inline struct dentry *debugfs_create_bool(const char *name, umode_t mode, |
---|
331 | 315 | struct dentry *parent, |
---|
.. | .. |
---|
341 | 325 | return ERR_PTR(-ENODEV); |
---|
342 | 326 | } |
---|
343 | 327 | |
---|
344 | | -static inline struct dentry *debugfs_create_regset32(const char *name, |
---|
345 | | - umode_t mode, struct dentry *parent, |
---|
346 | | - struct debugfs_regset32 *regset) |
---|
| 328 | +static inline void debugfs_create_regset32(const char *name, umode_t mode, |
---|
| 329 | + struct dentry *parent, |
---|
| 330 | + struct debugfs_regset32 *regset) |
---|
347 | 331 | { |
---|
348 | | - return ERR_PTR(-ENODEV); |
---|
349 | 332 | } |
---|
350 | 333 | |
---|
351 | 334 | static inline void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs, |
---|
.. | .. |
---|
358 | 341 | return false; |
---|
359 | 342 | } |
---|
360 | 343 | |
---|
361 | | -static inline struct dentry *debugfs_create_u32_array(const char *name, umode_t mode, |
---|
362 | | - struct dentry *parent, |
---|
363 | | - u32 *array, u32 elements) |
---|
| 344 | +static inline void debugfs_create_u32_array(const char *name, umode_t mode, |
---|
| 345 | + struct dentry *parent, |
---|
| 346 | + struct debugfs_u32_array *array) |
---|
364 | 347 | { |
---|
365 | | - return ERR_PTR(-ENODEV); |
---|
366 | 348 | } |
---|
367 | 349 | |
---|
368 | | -static inline struct dentry *debugfs_create_u32_array_hex(const char *name, umode_t mode, |
---|
369 | | - struct dentry *parent, |
---|
370 | | - u32 *array, u32 elements) |
---|
| 350 | +static inline void debugfs_create_devm_seqfile(struct device *dev, |
---|
| 351 | + const char *name, |
---|
| 352 | + struct dentry *parent, |
---|
| 353 | + int (*read_fn)(struct seq_file *s, |
---|
| 354 | + void *data)) |
---|
371 | 355 | { |
---|
372 | | - return ERR_PTR(-ENODEV); |
---|
373 | | -} |
---|
374 | | - |
---|
375 | | -static inline struct dentry *debugfs_create_devm_seqfile(struct device *dev, |
---|
376 | | - const char *name, |
---|
377 | | - struct dentry *parent, |
---|
378 | | - int (*read_fn)(struct seq_file *s, |
---|
379 | | - void *data)) |
---|
380 | | -{ |
---|
381 | | - return ERR_PTR(-ENODEV); |
---|
382 | 356 | } |
---|
383 | 357 | |
---|
384 | 358 | static inline ssize_t debugfs_read_file_bool(struct file *file, |
---|
.. | .. |
---|
397 | 371 | |
---|
398 | 372 | #endif |
---|
399 | 373 | |
---|
| 374 | +/** |
---|
| 375 | + * debugfs_create_xul - create a debugfs file that is used to read and write an |
---|
| 376 | + * unsigned long value, formatted in hexadecimal |
---|
| 377 | + * @name: a pointer to a string containing the name of the file to create. |
---|
| 378 | + * @mode: the permission that the file should have |
---|
| 379 | + * @parent: a pointer to the parent dentry for this file. This should be a |
---|
| 380 | + * directory dentry if set. If this parameter is %NULL, then the |
---|
| 381 | + * file will be created in the root of the debugfs filesystem. |
---|
| 382 | + * @value: a pointer to the variable that the file should read to and write |
---|
| 383 | + * from. |
---|
| 384 | + */ |
---|
| 385 | +static inline void debugfs_create_xul(const char *name, umode_t mode, |
---|
| 386 | + struct dentry *parent, |
---|
| 387 | + unsigned long *value) |
---|
| 388 | +{ |
---|
| 389 | + if (sizeof(*value) == sizeof(u32)) |
---|
| 390 | + debugfs_create_x32(name, mode, parent, (u32 *)value); |
---|
| 391 | + else |
---|
| 392 | + debugfs_create_x64(name, mode, parent, (u64 *)value); |
---|
| 393 | +} |
---|
| 394 | + |
---|
400 | 395 | #endif |
---|