diff options
author | Michael Ellerman <michael@ellerman.id.au> | 2007-04-17 01:59:36 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-04-27 13:57:31 -0400 |
commit | 8447891fe845851738439788c74b3c811578e3f9 (patch) | |
tree | 05834fbe797aa03a3db58dbc69e613a6afcd1a93 /fs | |
parent | 3106d46f51a1a72fdbf071ebc0800a9bcfcbc544 (diff) |
debugfs: Add debugfs_create_u64()
I went to use this the other day, only to find it didn't exist.
It's a straight copy of the debugfs u32 code, then s/u32/u64/. A quick
test shows it seems to be working.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/debugfs/file.c | 42 |
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 | } |
180 | EXPORT_SYMBOL_GPL(debugfs_create_u32); | 180 | EXPORT_SYMBOL_GPL(debugfs_create_u32); |
181 | 181 | ||
182 | static void debugfs_u64_set(void *data, u64 val) | ||
183 | { | ||
184 | *(u64 *)data = val; | ||
185 | } | ||
186 | |||
187 | static u64 debugfs_u64_get(void *data) | ||
188 | { | ||
189 | return *(u64 *)data; | ||
190 | } | ||
191 | DEFINE_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 | */ | ||
217 | struct 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 | } | ||
222 | EXPORT_SYMBOL_GPL(debugfs_create_u64); | ||
223 | |||
182 | static ssize_t read_file_bool(struct file *file, char __user *user_buf, | 224 | static 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 | { |