From 98210b7f73f1db182bd9a558a031093cd166e907 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Sun, 9 Nov 2014 11:31:58 +0100 Subject: debugfs: add helper function to create device related seq_file This patch adds a helper function that simplifies adding a so-called single_open sequence file for device drivers. The calling device driver needs to provide a read function and a device pointer. The field struct seq_file::private will reference the device pointer upon call to the read function so the driver can obtain his data from it and do its task of providing the file content using seq_printf() calls and alike. Using this helper function also gets rid of the need to specify file operations per debugfs file. Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- include/linux/debugfs.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'include/linux/debugfs.h') diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index 4d0b4d1aa132..4bbe2ace972a 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h @@ -99,13 +99,18 @@ struct dentry *debugfs_create_u32_array(const char *name, umode_t mode, struct dentry *parent, u32 *array, u32 elements); +struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name, + struct dentry *parent, + int (*read_fn)(struct seq_file *s, + void *data)); + bool debugfs_initialized(void); #else #include -/* +/* * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled * so users have a chance to detect if there was a real error or not. We don't * want to duplicate the design decision mistakes of procfs and devfs again. @@ -251,6 +256,15 @@ static inline struct dentry *debugfs_create_u32_array(const char *name, umode_t return ERR_PTR(-ENODEV); } +static inline struct dentry *debugfs_create_devm_seqfile(struct device *dev, + const char *name, + struct dentry *parent, + int (*read_fn)(struct seq_file *s, + void *data)) +{ + return ERR_PTR(-ENODEV); +} + #endif #endif -- cgit v1.2.3-59-g8ed1b From f30d0a815bb9b8ac1a3ab4d0c333d2379220d91d Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Sun, 30 Nov 2014 16:31:21 +0100 Subject: fs: debugfs: add forward declaration for struct device type The function debugfs_create_devm_seqfile() has a parameter of type struct device pointer. This type needs to be forward declared to avoid compilation issues on certain architectures and/or kernel configurations. The function was introduced with: commit 98210b7f73f1db182bd9a558a031093cd166e907 Author: Arend van Spriel Date: Sun Nov 9 11:31:58 2014 +0100 debugfs: add helper function to create device related seq_file The reported build failure for sparc64 architecture was: make.cross ARCH=sparc64 All warnings: In file included from fs/debugfs/file.c:21:0: include/linux/debugfs.h:105:10: warning: 'struct device' declared inside parameter list void *data)); ^ Reported-by: Fengguang Wu Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- include/linux/debugfs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/linux/debugfs.h') diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index 4bbe2ace972a..e3e9f31f91d2 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h @@ -20,6 +20,7 @@ #include +struct device; struct file_operations; struct debugfs_blob_wrapper { -- cgit v1.2.3-59-g8ed1b