mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Documentation: Update filesystems/debugfs.txt
@ 2015-07-16  6:31 Wang Long
  2015-07-16  9:37 ` Jonathan Corbet
  0 siblings, 1 reply; 2+ messages in thread
From: Wang Long @ 2015-07-16  6:31 UTC (permalink / raw)
  To: corbet
  Cc: gregkh, long.wanglong, rostedt, linux-doc, linux-kernel,
	peifeiyue, wanglong

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>
---
 Documentation/filesystems/debugfs.txt | 41 +++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/Documentation/filesystems/debugfs.txt b/Documentation/filesystems/debugfs.txt
index 88ab81c..b1ba8df 100644
--- a/Documentation/filesystems/debugfs.txt
+++ b/Documentation/filesystems/debugfs.txt
@@ -1,4 +1,5 @@
 Copyright 2009 Jonathan Corbet <corbet@lwn.net>
+Updated by Wang Long <long.wanglong@huawei.com> on 2015/07/16
 
 Debugfs exists as a simple way for kernel developers to make information
 available to user space.  Unlike /proc, which is only meant for information
@@ -51,6 +52,17 @@ operations should be provided; others can be included as needed.  Again,
 the return value will be a dentry pointer to the created file, NULL for
 error, or ERR_PTR(-ENODEV) if debugfs support is missing.
 
+Create a file with an initial size, the following function can be used
+instead:
+
+    struct dentry *debugfs_create_file_size(const char *name, umode_t mode,
+				struct dentry *parent, void *data,
+				const struct file_operations *fops,
+				loff_t file_size);
+
+file_size is the initial file size. The other parameters are the same
+as the function debugfs_create_file.
+
 In a number of cases, the creation of a set of file operations is not
 actually necessary; the debugfs code provides a number of helper functions
 for simple situations.  Files containing a single integer value can be
@@ -100,6 +112,14 @@ A read on the resulting file will yield either Y (for non-zero values) or
 N, followed by a newline.  If written to, it will accept either upper- or
 lower-case values, or 1 or 0.  Any other input will be silently ignored.
 
+Also, atomic_t values can be placed in debugfs with:
+
+    struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode,
+				struct dentry *parent, atomic_t *value)
+
+A read of this file will get atomic_t values, and a write of this file
+will set atomic_t values.
+
 Another option is exporting a block of arbitrary binary data, with
 this structure and function:
 
@@ -147,6 +167,27 @@ The "base" argument may be 0, but you may want to build the reg32 array
 using __stringify, and a number of register names (macros) are actually
 byte offsets over a base for the register block.
 
+If you want to dump an u32 array in debugfs, you can create file with:
+
+    struct dentry *debugfs_create_u32_array(const char *name, umode_t mode,
+			struct dentry *parent,
+			u32 *array, u32 elements);
+
+The "array" argument provides data, and the "elements" argument is
+the number of elements in the array. Note: Once array is created its
+size can not be changed.
+
+There is a helper function to create device related seq_file:
+
+   struct dentry *debugfs_create_devm_seqfile(struct device *dev,
+				const char *name,
+				struct dentry *parent,
+				int (*read_fn)(struct seq_file *s,
+					void *data));
+
+The "dev" argument is the device related to this debugfs file, and
+the "read_fn" is a function pointer which to be called to print the
+seq_file content.
 
 There are a couple of other directory-oriented helper functions:
 
-- 
1.8.3.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Documentation: Update filesystems/debugfs.txt
  2015-07-16  6:31 [PATCH] Documentation: Update filesystems/debugfs.txt Wang Long
@ 2015-07-16  9:37 ` Jonathan Corbet
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Corbet @ 2015-07-16  9:37 UTC (permalink / raw)
  To: Wang Long; +Cc: gregkh, rostedt, linux-doc, linux-kernel, peifeiyue, wanglong

On Thu, 16 Jul 2015 06:31:16 +0000
Wang Long <long.wanglong@huawei.com> wrote:

> 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

I'll apply this because it's a definite improvement over what is there
now, but it would be nice to describe these functions a bit more in
detail.  In particular, a name like debugfs_create_devm_seqfile() will
cause at least some developers to think it will clean itself up when the
device goes away, but that does not appear to actually be the case...

>  Copyright 2009 Jonathan Corbet <corbet@lwn.net>
> +Updated by Wang Long <long.wanglong@huawei.com> on 2015/07/16

I think I'll drop that line, though; that's what the source code
management system is for.  Arguably the line it follows doesn't really
need to be there either...

Thanks,

jon

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-16  9:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-16  6:31 [PATCH] Documentation: Update filesystems/debugfs.txt Wang Long
2015-07-16  9:37 ` Jonathan Corbet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome