diff options
Diffstat (limited to 'Documentation/filesystems/debugfs.txt')
-rw-r--r-- | Documentation/filesystems/debugfs.txt | 56 |
1 files changed, 43 insertions, 13 deletions
diff --git a/Documentation/filesystems/debugfs.txt b/Documentation/filesystems/debugfs.txt index 742cc06e138f..6872c91bce35 100644 --- a/Documentation/filesystems/debugfs.txt +++ b/Documentation/filesystems/debugfs.txt | |||
@@ -35,7 +35,7 @@ described below will work. | |||
35 | 35 | ||
36 | The most general way to create a file within a debugfs directory is with: | 36 | The most general way to create a file within a debugfs directory is with: |
37 | 37 | ||
38 | struct dentry *debugfs_create_file(const char *name, mode_t mode, | 38 | struct dentry *debugfs_create_file(const char *name, umode_t mode, |
39 | struct dentry *parent, void *data, | 39 | struct dentry *parent, void *data, |
40 | const struct file_operations *fops); | 40 | const struct file_operations *fops); |
41 | 41 | ||
@@ -53,13 +53,13 @@ actually necessary; the debugfs code provides a number of helper functions | |||
53 | for simple situations. Files containing a single integer value can be | 53 | for simple situations. Files containing a single integer value can be |
54 | created with any of: | 54 | created with any of: |
55 | 55 | ||
56 | struct dentry *debugfs_create_u8(const char *name, mode_t mode, | 56 | struct dentry *debugfs_create_u8(const char *name, umode_t mode, |
57 | struct dentry *parent, u8 *value); | 57 | struct dentry *parent, u8 *value); |
58 | struct dentry *debugfs_create_u16(const char *name, mode_t mode, | 58 | struct dentry *debugfs_create_u16(const char *name, umode_t mode, |
59 | struct dentry *parent, u16 *value); | 59 | struct dentry *parent, u16 *value); |
60 | struct dentry *debugfs_create_u32(const char *name, mode_t mode, | 60 | struct dentry *debugfs_create_u32(const char *name, umode_t mode, |
61 | struct dentry *parent, u32 *value); | 61 | struct dentry *parent, u32 *value); |
62 | struct dentry *debugfs_create_u64(const char *name, mode_t mode, | 62 | struct dentry *debugfs_create_u64(const char *name, umode_t mode, |
63 | struct dentry *parent, u64 *value); | 63 | struct dentry *parent, u64 *value); |
64 | 64 | ||
65 | These files support both reading and writing the given value; if a specific | 65 | These files support both reading and writing the given value; if a specific |
@@ -67,13 +67,13 @@ file should not be written to, simply set the mode bits accordingly. The | |||
67 | values in these files are in decimal; if hexadecimal is more appropriate, | 67 | values in these files are in decimal; if hexadecimal is more appropriate, |
68 | the following functions can be used instead: | 68 | the following functions can be used instead: |
69 | 69 | ||
70 | struct dentry *debugfs_create_x8(const char *name, mode_t mode, | 70 | struct dentry *debugfs_create_x8(const char *name, umode_t mode, |
71 | struct dentry *parent, u8 *value); | 71 | struct dentry *parent, u8 *value); |
72 | struct dentry *debugfs_create_x16(const char *name, mode_t mode, | 72 | struct dentry *debugfs_create_x16(const char *name, umode_t mode, |
73 | struct dentry *parent, u16 *value); | 73 | struct dentry *parent, u16 *value); |
74 | struct dentry *debugfs_create_x32(const char *name, mode_t mode, | 74 | struct dentry *debugfs_create_x32(const char *name, umode_t mode, |
75 | struct dentry *parent, u32 *value); | 75 | struct dentry *parent, u32 *value); |
76 | struct dentry *debugfs_create_x64(const char *name, mode_t mode, | 76 | struct dentry *debugfs_create_x64(const char *name, umode_t mode, |
77 | struct dentry *parent, u64 *value); | 77 | struct dentry *parent, u64 *value); |
78 | 78 | ||
79 | These functions are useful as long as the developer knows the size of the | 79 | These functions are useful as long as the developer knows the size of the |
@@ -81,7 +81,7 @@ value to be exported. Some types can have different widths on different | |||
81 | architectures, though, complicating the situation somewhat. There is a | 81 | architectures, though, complicating the situation somewhat. There is a |
82 | function meant to help out in one special case: | 82 | function meant to help out in one special case: |
83 | 83 | ||
84 | struct dentry *debugfs_create_size_t(const char *name, mode_t mode, | 84 | struct dentry *debugfs_create_size_t(const char *name, umode_t mode, |
85 | struct dentry *parent, | 85 | struct dentry *parent, |
86 | size_t *value); | 86 | size_t *value); |
87 | 87 | ||
@@ -90,21 +90,22 @@ a variable of type size_t. | |||
90 | 90 | ||
91 | Boolean values can be placed in debugfs with: | 91 | Boolean values can be placed in debugfs with: |
92 | 92 | ||
93 | struct dentry *debugfs_create_bool(const char *name, mode_t mode, | 93 | struct dentry *debugfs_create_bool(const char *name, umode_t mode, |
94 | struct dentry *parent, u32 *value); | 94 | struct dentry *parent, u32 *value); |
95 | 95 | ||
96 | A read on the resulting file will yield either Y (for non-zero values) or | 96 | A read on the resulting file will yield either Y (for non-zero values) or |
97 | N, followed by a newline. If written to, it will accept either upper- or | 97 | N, followed by a newline. If written to, it will accept either upper- or |
98 | lower-case values, or 1 or 0. Any other input will be silently ignored. | 98 | lower-case values, or 1 or 0. Any other input will be silently ignored. |
99 | 99 | ||
100 | Finally, a block of arbitrary binary data can be exported with: | 100 | Another option is exporting a block of arbitrary binary data, with |
101 | this structure and function: | ||
101 | 102 | ||
102 | struct debugfs_blob_wrapper { | 103 | struct debugfs_blob_wrapper { |
103 | void *data; | 104 | void *data; |
104 | unsigned long size; | 105 | unsigned long size; |
105 | }; | 106 | }; |
106 | 107 | ||
107 | struct dentry *debugfs_create_blob(const char *name, mode_t mode, | 108 | struct dentry *debugfs_create_blob(const char *name, umode_t mode, |
108 | struct dentry *parent, | 109 | struct dentry *parent, |
109 | struct debugfs_blob_wrapper *blob); | 110 | struct debugfs_blob_wrapper *blob); |
110 | 111 | ||
@@ -115,6 +116,35 @@ can be used to export binary information, but there does not appear to be | |||
115 | any code which does so in the mainline. Note that all files created with | 116 | any code which does so in the mainline. Note that all files created with |
116 | debugfs_create_blob() are read-only. | 117 | debugfs_create_blob() are read-only. |
117 | 118 | ||
119 | If you want to dump a block of registers (something that happens quite | ||
120 | often during development, even if little such code reaches mainline. | ||
121 | Debugfs offers two functions: one to make a registers-only file, and | ||
122 | another to insert a register block in the middle of another sequential | ||
123 | file. | ||
124 | |||
125 | struct debugfs_reg32 { | ||
126 | char *name; | ||
127 | unsigned long offset; | ||
128 | }; | ||
129 | |||
130 | struct debugfs_regset32 { | ||
131 | struct debugfs_reg32 *regs; | ||
132 | int nregs; | ||
133 | void __iomem *base; | ||
134 | }; | ||
135 | |||
136 | struct dentry *debugfs_create_regset32(const char *name, mode_t mode, | ||
137 | struct dentry *parent, | ||
138 | struct debugfs_regset32 *regset); | ||
139 | |||
140 | int debugfs_print_regs32(struct seq_file *s, struct debugfs_reg32 *regs, | ||
141 | int nregs, void __iomem *base, char *prefix); | ||
142 | |||
143 | The "base" argument may be 0, but you may want to build the reg32 array | ||
144 | using __stringify, and a number of register names (macros) are actually | ||
145 | byte offsets over a base for the register block. | ||
146 | |||
147 | |||
118 | There are a couple of other directory-oriented helper functions: | 148 | There are a couple of other directory-oriented helper functions: |
119 | 149 | ||
120 | struct dentry *debugfs_rename(struct dentry *old_dir, | 150 | struct dentry *debugfs_rename(struct dentry *old_dir, |