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 | |
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>
-rw-r--r-- | fs/debugfs/file.c | 42 | ||||
-rw-r--r-- | include/linux/debugfs.h | 9 |
2 files changed, 51 insertions, 0 deletions
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 682f928b7f4..2e124e0075c 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 | { |
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index 9fa0983d1aa..5a9c49534d0 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h | |||
@@ -44,6 +44,8 @@ struct dentry *debugfs_create_u16(const char *name, mode_t mode, | |||
44 | struct dentry *parent, u16 *value); | 44 | struct dentry *parent, u16 *value); |
45 | struct dentry *debugfs_create_u32(const char *name, mode_t mode, | 45 | struct dentry *debugfs_create_u32(const char *name, mode_t mode, |
46 | struct dentry *parent, u32 *value); | 46 | struct dentry *parent, u32 *value); |
47 | struct dentry *debugfs_create_u64(const char *name, mode_t mode, | ||
48 | struct dentry *parent, u64 *value); | ||
47 | struct dentry *debugfs_create_bool(const char *name, mode_t mode, | 49 | struct dentry *debugfs_create_bool(const char *name, mode_t mode, |
48 | struct dentry *parent, u32 *value); | 50 | struct dentry *parent, u32 *value); |
49 | 51 | ||
@@ -104,6 +106,13 @@ static inline struct dentry *debugfs_create_u32(const char *name, mode_t mode, | |||
104 | return ERR_PTR(-ENODEV); | 106 | return ERR_PTR(-ENODEV); |
105 | } | 107 | } |
106 | 108 | ||
109 | static inline struct dentry *debugfs_create_u64(const char *name, mode_t mode, | ||
110 | struct dentry *parent, | ||
111 | u64 *value) | ||
112 | { | ||
113 | return ERR_PTR(-ENODEV); | ||
114 | } | ||
115 | |||
107 | static inline struct dentry *debugfs_create_bool(const char *name, mode_t mode, | 116 | static inline struct dentry *debugfs_create_bool(const char *name, mode_t mode, |
108 | struct dentry *parent, | 117 | struct dentry *parent, |
109 | u32 *value) | 118 | u32 *value) |