aboutsummaryrefslogtreecommitdiffstats
path: root/fs/debugfs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/debugfs/file.c')
-rw-r--r--fs/debugfs/file.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 682f928b7f4d..2e124e0075c5 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -179,6 +179,48 @@ struct dentry *debugfs_create_u32(const char *name, mode_t mode,
179} 179}
180EXPORT_SYMBOL_GPL(debugfs_create_u32); 180EXPORT_SYMBOL_GPL(debugfs_create_u32);
181 181
182static void debugfs_u64_set(void *data, u64 val)
183{
184 *(u64 *)data = val;
185}
186
187static u64 debugfs_u64_get(void *data)
188{
189 return *(u64 *)data;
190}
191DEFINE_SIMPLE_ATTRIBUTE(fops_u64, debugfs_u64_get, debugfs_u64_set, "%llu\n");
192
193/**
194 * debugfs_create_u64 - create a debugfs file that is used to read and write an unsigned 64-bit value
195 * @name: a pointer to a string containing the name of the file to create.
196 * @mode: the permission that the file should have
197 * @parent: a pointer to the parent dentry for this file. This should be a
198 * directory dentry if set. If this parameter is %NULL, then the
199 * file will be created in the root of the debugfs filesystem.
200 * @value: a pointer to the variable that the file should read to and write
201 * from.
202 *
203 * This function creates a file in debugfs with the given name that
204 * contains the value of the variable @value. If the @mode variable is so
205 * set, it can be read from, and written to.
206 *
207 * This function will return a pointer to a dentry if it succeeds. This
208 * pointer must be passed to the debugfs_remove() function when the file is
209 * to be removed (no automatic cleanup happens if your module is unloaded,
210 * you are responsible here.) If an error occurs, %NULL will be returned.
211 *
212 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
213 * returned. It is not wise to check for this value, but rather, check for
214 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
215 * code.
216 */
217struct dentry *debugfs_create_u64(const char *name, mode_t mode,
218 struct dentry *parent, u64 *value)
219{
220 return debugfs_create_file(name, mode, parent, value, &fops_u64);
221}
222EXPORT_SYMBOL_GPL(debugfs_create_u64);
223
182static ssize_t read_file_bool(struct file *file, char __user *user_buf, 224static ssize_t read_file_bool(struct file *file, char __user *user_buf,
183 size_t count, loff_t *ppos) 225 size_t count, loff_t *ppos)
184{ 226{