aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/debugfs/file.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 8450549d54a9..d2ba12e23ed9 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -243,6 +243,54 @@ struct dentry *debugfs_create_u64(const char *name, umode_t mode,
243} 243}
244EXPORT_SYMBOL_GPL(debugfs_create_u64); 244EXPORT_SYMBOL_GPL(debugfs_create_u64);
245 245
246static int debugfs_ulong_set(void *data, u64 val)
247{
248 *(unsigned long *)data = val;
249 return 0;
250}
251
252static int debugfs_ulong_get(void *data, u64 *val)
253{
254 *val = *(unsigned long *)data;
255 return 0;
256}
257DEFINE_SIMPLE_ATTRIBUTE(fops_ulong, debugfs_ulong_get, debugfs_ulong_set, "%llu\n");
258DEFINE_SIMPLE_ATTRIBUTE(fops_ulong_ro, debugfs_ulong_get, NULL, "%llu\n");
259DEFINE_SIMPLE_ATTRIBUTE(fops_ulong_wo, NULL, debugfs_ulong_set, "%llu\n");
260
261/**
262 * debugfs_create_ulong - create a debugfs file that is used to read and write
263 * an unsigned long value.
264 * @name: a pointer to a string containing the name of the file to create.
265 * @mode: the permission that the file should have
266 * @parent: a pointer to the parent dentry for this file. This should be a
267 * directory dentry if set. If this parameter is %NULL, then the
268 * file will be created in the root of the debugfs filesystem.
269 * @value: a pointer to the variable that the file should read to and write
270 * from.
271 *
272 * This function creates a file in debugfs with the given name that
273 * contains the value of the variable @value. If the @mode variable is so
274 * set, it can be read from, and written to.
275 *
276 * This function will return a pointer to a dentry if it succeeds. This
277 * pointer must be passed to the debugfs_remove() function when the file is
278 * to be removed (no automatic cleanup happens if your module is unloaded,
279 * you are responsible here.) If an error occurs, %NULL will be returned.
280 *
281 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
282 * returned. It is not wise to check for this value, but rather, check for
283 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
284 * code.
285 */
286struct dentry *debugfs_create_ulong(const char *name, umode_t mode,
287 struct dentry *parent, unsigned long *value)
288{
289 return debugfs_create_mode(name, mode, parent, value, &fops_ulong,
290 &fops_ulong_ro, &fops_ulong_wo);
291}
292EXPORT_SYMBOL_GPL(debugfs_create_ulong);
293
246DEFINE_SIMPLE_ATTRIBUTE(fops_x8, debugfs_u8_get, debugfs_u8_set, "0x%02llx\n"); 294DEFINE_SIMPLE_ATTRIBUTE(fops_x8, debugfs_u8_get, debugfs_u8_set, "0x%02llx\n");
247DEFINE_SIMPLE_ATTRIBUTE(fops_x8_ro, debugfs_u8_get, NULL, "0x%02llx\n"); 295DEFINE_SIMPLE_ATTRIBUTE(fops_x8_ro, debugfs_u8_get, NULL, "0x%02llx\n");
248DEFINE_SIMPLE_ATTRIBUTE(fops_x8_wo, NULL, debugfs_u8_set, "0x%02llx\n"); 296DEFINE_SIMPLE_ATTRIBUTE(fops_x8_wo, NULL, debugfs_u8_set, "0x%02llx\n");