diff options
| author | Wang Long <long.wanglong@huawei.com> | 2015-07-16 02:31:16 -0400 |
|---|---|---|
| committer | Jonathan Corbet <corbet@lwn.net> | 2015-07-24 09:05:56 -0400 |
| commit | 9e1aa7c8882050577c9223ba85c4ee49cd1da469 (patch) | |
| tree | db1429b609a425578286d96bb1d805250ebeb1b8 /Documentation/filesystems | |
| parent | a10726bb5472ff2ed95180cfb5e82091c45d7b19 (diff) | |
Documentation: Update filesystems/debugfs.txt
This patch update the Documentation/filesystems/debugfs.txt
file. The main work is to add the description of the following
functions:
debugfs_create_atomic_t
debugfs_create_u32_array
debugfs_create_devm_seqfile
debugfs_create_file_size
Signed-off-by: Wang Long <long.wanglong@huawei.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'Documentation/filesystems')
| -rw-r--r-- | Documentation/filesystems/debugfs.txt | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Documentation/filesystems/debugfs.txt b/Documentation/filesystems/debugfs.txt index 88ab81c79109..463f595733e8 100644 --- a/Documentation/filesystems/debugfs.txt +++ b/Documentation/filesystems/debugfs.txt | |||
| @@ -51,6 +51,17 @@ operations should be provided; others can be included as needed. Again, | |||
| 51 | the return value will be a dentry pointer to the created file, NULL for | 51 | the return value will be a dentry pointer to the created file, NULL for |
| 52 | error, or ERR_PTR(-ENODEV) if debugfs support is missing. | 52 | error, or ERR_PTR(-ENODEV) if debugfs support is missing. |
| 53 | 53 | ||
| 54 | Create a file with an initial size, the following function can be used | ||
| 55 | instead: | ||
| 56 | |||
| 57 | struct dentry *debugfs_create_file_size(const char *name, umode_t mode, | ||
| 58 | struct dentry *parent, void *data, | ||
| 59 | const struct file_operations *fops, | ||
| 60 | loff_t file_size); | ||
| 61 | |||
| 62 | file_size is the initial file size. The other parameters are the same | ||
| 63 | as the function debugfs_create_file. | ||
| 64 | |||
| 54 | In a number of cases, the creation of a set of file operations is not | 65 | In a number of cases, the creation of a set of file operations is not |
| 55 | actually necessary; the debugfs code provides a number of helper functions | 66 | actually necessary; the debugfs code provides a number of helper functions |
| 56 | for simple situations. Files containing a single integer value can be | 67 | for simple situations. Files containing a single integer value can be |
| @@ -100,6 +111,14 @@ A read on the resulting file will yield either Y (for non-zero values) or | |||
| 100 | N, followed by a newline. If written to, it will accept either upper- or | 111 | N, followed by a newline. If written to, it will accept either upper- or |
| 101 | lower-case values, or 1 or 0. Any other input will be silently ignored. | 112 | lower-case values, or 1 or 0. Any other input will be silently ignored. |
| 102 | 113 | ||
| 114 | Also, atomic_t values can be placed in debugfs with: | ||
| 115 | |||
| 116 | struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode, | ||
| 117 | struct dentry *parent, atomic_t *value) | ||
| 118 | |||
| 119 | A read of this file will get atomic_t values, and a write of this file | ||
| 120 | will set atomic_t values. | ||
| 121 | |||
| 103 | Another option is exporting a block of arbitrary binary data, with | 122 | Another option is exporting a block of arbitrary binary data, with |
| 104 | this structure and function: | 123 | this structure and function: |
| 105 | 124 | ||
| @@ -147,6 +166,27 @@ The "base" argument may be 0, but you may want to build the reg32 array | |||
| 147 | using __stringify, and a number of register names (macros) are actually | 166 | using __stringify, and a number of register names (macros) are actually |
| 148 | byte offsets over a base for the register block. | 167 | byte offsets over a base for the register block. |
| 149 | 168 | ||
| 169 | If you want to dump an u32 array in debugfs, you can create file with: | ||
| 170 | |||
| 171 | struct dentry *debugfs_create_u32_array(const char *name, umode_t mode, | ||
| 172 | struct dentry *parent, | ||
| 173 | u32 *array, u32 elements); | ||
| 174 | |||
| 175 | The "array" argument provides data, and the "elements" argument is | ||
| 176 | the number of elements in the array. Note: Once array is created its | ||
| 177 | size can not be changed. | ||
| 178 | |||
| 179 | There is a helper function to create device related seq_file: | ||
| 180 | |||
| 181 | struct dentry *debugfs_create_devm_seqfile(struct device *dev, | ||
| 182 | const char *name, | ||
| 183 | struct dentry *parent, | ||
| 184 | int (*read_fn)(struct seq_file *s, | ||
| 185 | void *data)); | ||
| 186 | |||
| 187 | The "dev" argument is the device related to this debugfs file, and | ||
| 188 | the "read_fn" is a function pointer which to be called to print the | ||
| 189 | seq_file content. | ||
| 150 | 190 | ||
| 151 | There are a couple of other directory-oriented helper functions: | 191 | There are a couple of other directory-oriented helper functions: |
| 152 | 192 | ||
