aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/debugfs.h
diff options
context:
space:
mode:
authorArend van Spriel <arend@broadcom.com>2014-11-09 05:31:58 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-11-26 22:38:37 -0500
commit98210b7f73f1db182bd9a558a031093cd166e907 (patch)
tree93b0c862e237d963e9ad9a8d2ff8e5b0e222b8fd /include/linux/debugfs.h
parent6df43c9b4d87b6767debdfa8318c5374415e8fc0 (diff)
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 <arend@broadcom.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/debugfs.h')
-rw-r--r--include/linux/debugfs.h16
1 files changed, 15 insertions, 1 deletions
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,
99 struct dentry *parent, 99 struct dentry *parent,
100 u32 *array, u32 elements); 100 u32 *array, u32 elements);
101 101
102struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name,
103 struct dentry *parent,
104 int (*read_fn)(struct seq_file *s,
105 void *data));
106
102bool debugfs_initialized(void); 107bool debugfs_initialized(void);
103 108
104#else 109#else
105 110
106#include <linux/err.h> 111#include <linux/err.h>
107 112
108/* 113/*
109 * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled 114 * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled
110 * so users have a chance to detect if there was a real error or not. We don't 115 * so users have a chance to detect if there was a real error or not. We don't
111 * want to duplicate the design decision mistakes of procfs and devfs again. 116 * 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
251 return ERR_PTR(-ENODEV); 256 return ERR_PTR(-ENODEV);
252} 257}
253 258
259static inline struct dentry *debugfs_create_devm_seqfile(struct device *dev,
260 const char *name,
261 struct dentry *parent,
262 int (*read_fn)(struct seq_file *s,
263 void *data))
264{
265 return ERR_PTR(-ENODEV);
266}
267
254#endif 268#endif
255 269
256#endif 270#endif